如何将 eclipse 项目添加到现有的 git repo?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13131366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add eclipse project to existing git repo?
提问by Lanaru
I already have an existing project in Eclipse that I want to add to my team's github repo. The github repo is empty right now. What's the best way to add this project to our github repo? I was thinking of git clone
ing our repo into the workspace folder (parent to the project in question) and then adding the project files using git add
, then pushing
the changes. Would that work, or is there a better way to do this (perhaps with EGit)?
我已经在 Eclipse 中有一个现有项目,我想将其添加到我团队的 github 存储库中。github 存储库现在是空的。将此项目添加到我们的 github 存储库的最佳方法是什么?我正在考虑将git clone
我们的 repo 放入工作区文件夹(相关项目的父级),然后使用添加项目文件git add
,然后添加pushing
更改。这会起作用,还是有更好的方法来做到这一点(也许使用 EGit)?
回答by redShadow
You have to add a remote to the project, and then push to it.
您必须向项目添加一个遥控器,然后推送到它。
For example, you can do (from inside the project directory)
例如,您可以执行(从项目目录中)
git init # if you haven't already
git remote add origin ssh://[email protected]:.....
git push -u origin master
there should be a way to do that from the eclipse plugin too, but I find it easiear to do it from the command line.. :)
也应该有一种方法可以从 eclipse 插件中做到这一点,但我发现从命令行中很容易做到这一点.. :)
By the way, remember to add all the IDE-specific files to .gitignore
, to avoid pushing garbage to the world: they usually are .project
, .classpath
and directories like bin/*
,.settings/*
...
顺便说一句,记住将所有特定于 IDE 的文件添加到.gitignore
,以避免将垃圾推向世界:它们通常是 .project
,.classpath
以及诸如bin/*
, .settings/*
...