如何将Eclipse项目上传到GitHub? [英] How Do I Upload Eclipse Projects to GitHub?
问题描述
虽然Eclipse的EGit插件是一个很好的选择,更好一个是学习使用git bash - 即git从命令行。了解git的基础知识并不是非常困难的,在依靠GUI进行操作之前了解一些基本操作通常是非常有益的。但是要回答你的问题:
首先,从 http:// git -scm.com/ 。然后转到 http://github.com/ 并创建一个帐户和存储库。
在您的机器上,首先您需要使用git bash导航到项目文件夹。当你到达那里你要做:
git init
在该目录中启动一个新的git仓库。
完成后,您需要注册新的远程(你要上传的东西 - 推送你的文件),这在这种情况下是github。您将在GitHub上从您的回购站获取正确的URL。
$ git remote add origin https://github.com/ [username] / [reponame] .git
您需要将现有文件添加到本地提交中:
git add。 #这会添加所有文件
然后,您需要进行初始提交,因此您可以: p>
git commit -a -m初始提交#这会将您的文件在本地进行提交。
#他们还没有被推送
现在您已经创建了一个提交你当地的回购,但不在遥远的一个。要把它放在遥控器上,你做你发布的第二行:
git push -u origin --all
I have code in Eclipse that I'd like to upload to GitHub but so far I can't figure out how. It says "create a repository" but that looks more like a folder that holds your projects and I'm not sure how to upload my code to it. Apologies for the seemingly dumb question. Also, how does one delete repositories? Didn't see a way to do that either.
While the EGit plugin for Eclipse is a good option, an even better one would be to learn to use git bash -- i.e., git from the command line. It isn't terribly difficult to learn the very basics of git, and it is often very benefitial to understand some basic operations before relying on a GUI to do it for you. But to answer your question:
First things first, download git from http://git-scm.com/. Then go to http://github.com/ and create an account and repository.
On your machine, first you will need to navigate to the project folder using git bash. When you get there you do:
git init
which initiates a new git repository in that directory.
When you've done that, you need to register that new repo with a remote (where you'll upload -- push -- your files to), which in this case will be github. You'll get the correct URL from your repo on GitHub.
$ git remote add origin https://github.com/[username]/[reponame].git
You need to add you existing files to your local commit:
git add . # this adds all the files
Then you need to make an initial commit, so you do:
git commit -a -m "Initial commit" # this stages your files locally for commit.
# they haven't actually been pushed yet
Now you've created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:
git push -u origin --all
这篇关于如何将Eclipse项目上传到GitHub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!