Wednesday 23 May 2012

Configuring the EGit Plugin for Eclipse

Configuring the EGit Plugin for Eclipse

EGit is an Eclipse Team provider for the Git version control system. Git is a distributed SCM, which means every developer has a full copy of all history of every revision of the code, making queries against the history very fast and versatile. The EGit project is implementing Eclipse tooling on top of the JGit Java implementation of Git.

Installing the EGit plugin from within Eclipse

From the Eclipse menu bar click Help > Install New Software. The following window (Figure 1-1) should pop up. You don't need to add an update site URL since Eclipse will find it automatically.
Figure 1-1 - Install New Software
Figure 1-1 - Install New Software
  • In the "Work with" drop down select "--All Available Sites--"
  • In the field that reads "type filter text" type: Git
  • The area below should automatically populate after a few seconds with a few options for the EGit plugin listed. Check the option as listed in Figure 1-2 (Collaboration > Eclipse EGit (Incubation))
  • Click "Next"
  • Click Finish
Figure 1-2 - EGit Plugin
Figure 1-2 - EGit Plugin

Share your project

Now you need to get your files into the repository which means configuring the connection to GitHub from Eclipse. I've heard this part is not supposed to require anything special but I ran into a couple quirks. Fortunately I found some great resources online to help. They are listed at the end of this post.
  • Make sure your main development perspective (Java, PHP, JavaScript) is selected.
  • Right click your project and click Team > Share Project...
  • In the window that pops up select Git and click "Next"
  • If you have already set up a local git repo (i.e., you've run "git init") then you should see your project listed in this window
  • Make sure the box next to your project repo is checked and click "Finish"
Now when you right click your project name again, and click "Team" you will see a whole new menu. You should be able to commit and push from here without any other issues. I was not able to however. Come to find out, my SSH path was off (or something) and I was getting an "Auth failed" message from GitHub. If you are in the same jam, follow this step.
  • In the Eclipse menu bar click Window > Preferences
  • Navigate to General > Network Connections > SSH2
  • Click the General tab (it should be selected by default) & make sure your "SSH2 home" path is correct. Mine was set to "C:\Users\Dennis\ssh" and it needed to be set to "C:\Users\Dennis\.ssh" (whoops)
  • Next click the Key Management tab, then click the "Load Existing Key" button
  • In the window that pops up navigate to your .ssh directory and select the id_rsa file and click "Open".
  • Click "OK"
Now you should be able to commit and push if you weren't able to before. I may have missed a detail or two since I'm making this post after I already set up my connection without documenting it or taking screenshots along the way :\

In closing

Hopefully this has provided you with some helpful info. If you've got any questions please drop them in the comments below. They're more likely to get answered there either by me or someone else as this is a fairly highly trafficked blog.
Thanks for reading!

Helpful Articles

http://stackoverflow.com/questions/3601805/auth-problem-with-egit-and-github
http://www.eclipse.org/forums/index.php?t=msg&goto=648905&S=9bcfa96ab726d744d41a19c7fb02d723#msg_648905

First is first:

wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
yum install git

Next steps, configure git configuraiton:

git config --global user.name "Basil Abbas"
git config --global user.email "basil@isu.net.sa"
git config --global color.ui auto

Creating a bare repository on a remote server:

mkdir project_directory
cd project_directory
git init --bare

Cloning the bare remote repository on a development machine:

cd /home/babbas
git clone ssh://hostname/path/to/project_directory

No comments:

Post a Comment