How do I create a remote git repository in EGit and link it to an existing Eclipse project?

Dan Largo picture Dan Largo · Apr 26, 2011 · Viewed 39.1k times · Source

I am using Eclipse Helios and EGit. I am new to Git. I have an existing Eclipse project for an Android app I would like to place in Git. Can someone please share some instructions on how to setup a Git repo on a shared folder, and place the existing project into this git repo using EGit? I have tried a variety of options with no success.

Thanks!

Answer

Asenar picture Asenar · Aug 5, 2013

I had the same question (how to do it in Eclipse / eGit), and I just found the answer to the question stated in the title :

  1. go in Window > Show Views > Others select Git repositories
  2. expand the repository to see "Remotes", right click and Create Remote
  3. choose the option : fetch will tell eclipse you're only allowed to read (which is the correct option if you don't want/have the right to push on that repo). then name that remote repository like you want (the first is usually named "origin", but you can have "prod", "test-server", ...)
  4. click on change to specify the uri of the repository. You can paste on the first field the complete uri you would type after "git clone".
  5. "Finish" then "Save and Push" or "Save and Fetch" according to what you choosed in 3°

Also, for creating a new project in Eclipse from an existing git repository with eGit, all you have to do is to go in File > Import...and choosing Git/Projects from Git. Then follow the steps