Lanaru
Lanaru

Reputation: 9721

How to add eclipse project to existing git repo?

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 cloneing 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)?

Upvotes: 4

Views: 12794

Answers (1)

redShadow
redShadow

Reputation: 6777

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.. :)

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/* ...

Upvotes: 7

Related Questions