Eclipse and Git

From Redbrick Wiki

So after having a bit of a head bashing session getting an eclipse project to work nicely with a git repository hosted on github, I thought I'd throw my approach up here to save others torture.

Eclipse git plugin

I'm using EGit.

I used Eclipse's Update Manager, adding http://download.eclipse.org/egit/updates as the site for the plugin.

Eclipse Project

I went about setting up my project in eclipse as per usual, noting the location of my workspace.

Git Repo

I'm using ubuntu, so I installed the necessary git tools with the following command:


sudo apt-get install git-core


I then opened a terminal and cd'd to the location of my project in the eclipse workspace, noted above.


cd /home/dregin/workspace/Project-Name/


I then set up a .git repo following the steps provided by github, here.


git config --global user.name "My Name"

git config --global user.email email@address.com


NOTE: At this point the steps want you to create/move into a directory, but we're already in the directory we're going to use.


git init

git add .

git commit -m 'My first commit'

git remote add origin git@github.com:username/repository-name.git

push origin master


NOTE: If this isn't your first commit to the repository you plan on using you should merge with the remote repository as follows:


git fetch origin

git merge origin/master

push origin master


Making Eclipse Play With The New Repo

  • In the package explorer, right-click on the package name.
    • Team > Share Project.
  • Choose "Git".

It should see the repository that you setup above.

  • Click Finish.

That should be you done.

This page is a shit on the face of style. Please fix it.