Factsheet
egit - Creating and sharing a git repository in Eclipse - Stack Overflow
How do I configure Eclipse to use an existing git repository with existing source code? - Stack Overflow
Eclipse/Git: How to add a project to GitHub without unnecessary parent folder
How do I create a remote git repository in EGit and link it to an existing Eclipse project? - Stack Overflow
Videos
After much putzing around, I finally figured it out. Once you import the project from the git repository into the eclipse workspace, you then team->share it back to the same repository and it will attach it. Not sure why this is a two step process but that's how I made it go. Maybe there's a simpler way, but I haven't found it yet.
I had this issue as well. And I'm not sure if you are going about things the same way I did. But just to compare, I imported a project from GitHub and used the "New Project Wizard" when prompted by Eclipse. This wizard asks me to select a directory for the project. And if the directory selected there is different from the directory that the Import Wizard used to import the git repo, of course, the project is not linked.
Instead of going about the team->share method, upon importing the project (with the New Project Wizard) I made sure that the New Project Wizard used the same directory as the Import Wizard (the one the repo imported uses).
If you are able to instead Import Existing Projects, for some reason it connects everything automatically without opening the New Project Wizard.
I suppose the New Project Wizard adds one unnecessary step in this particular use case (since we can assume you mean for the imported repo to be automatically connected.
Just an observation.
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 :
- either go to
Window>Show View>Other...then selectGit>Git repositoriesor click the Git repositories icon in the set of icons in the right - expand the repository to see "Remotes", right click and
Create Remote - 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", ...)
- 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"; if in GitHub you first copy the uri then it might be automatically filled in
- "Finish" then "Save and Push" or "Save and Fetch" according to what you chose 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
You can do everything from the command line instead:
Do this in the root of the project:
git init
Do the same in the folder where you want your blessed or central repository:
git init --bare
In the local repository, add a readme file and commit it:
echo "testing" > readme
git add readme
git commit -m "initial commit"
Now link and push your changes to the central repository:
git remote add origin //server/share/repodir
git push -u origin master
Hope this gets you started.
You can use egit later if you like, but there is nothing wrong with using git separately.