Installing and using egit, the eclipse git plugin

I use the latest PDT version of eclipse (Helios) as my IDE of choice, and have used the built-in cvs and add-on svn-kit plugins for version control for many years. When I first started using git, I guess I didn't think there was a git plug-in for eclipse or that the ones I saw just weren't stable enough, so I just went to the command line to do the git work then back to eclipse to continue coding. Now that Drupal has moved their whole repository from cvs to git, I thought it might be time to add the e-git plug-in to eclipse so that I don't have to leave eclipse to get git work done. That's the point of using and IDE isn't it?

First if you don't already have git installed on your laptop/desktop I suggest you follow the instructions for that at github, this link will redirect to the appropriate OS it detects that you are using.

To install e-git, go to preferences, in linux it's in the Window menu, in Mac OSx it's in the File, I think it's the same as the Mac for Windows. In preferences go to Install/Update -> Available Software Sites. If Eclipse Git Team Provider is not listed then you have to click on add and enter http://download.eclipse.org/egit/updates as the site for egit, If it is listed, just enable it. Next, go to Help -> Install New Software. In the "Work with" drop down select "Eclipse Git Team Provider", then check Eclipse JGit under JGit and Eclipse EGit under Eclipse Git Team Provider, click next and accept the license agreement and you'll be prompted to restart eclipse when you're finished. If all goes well, you should see a new tab under Team in the preferences window for Git. Since I'm a php web developer, I've set my Default Repo folder to /var/www here. Then click on Configuration and add 2 new key/value pair entries, the first is user.name (put what you'd like here but I think it should be your true name), and the second is user.email (use the name you've used/will use with the repos you are going to be an active participant of). These 2 values are used along with your public key to make sure you're you when you want to push to the repo of origin.

Now comes the trickiest part of the eclipse/git integration. I tried to create a php project then outside of eclipse do a git init but noticed that in eclipse the team menu only had "apply patch", so that wasn't the way to add git integration. I tried a couple of other things but nothing gave me what I needed.
The process I use for creating a new php project with git integration now is, open the Git Repos view, click on Add Git Repo, add a new repo here with an absolute path such as /var/www/new-repo and click finish. Next, right click on the new repo in the view and select "import projects". Under Method for project creation select "Use the New Projects wizard" and under "Method for sharing projects after project creation" select "Try to share newly created projects automatically" and click finish. Now the New Project wizard will start, expand PHP to reveal PHP Project, select that and click next. In the new php project under Project name type new-repo or whatever you just named the repo you just created, check the box for javascript support if you like and click on finish. The first time you do this you'll get another dialog that asks if you'd like to open the Associated perspective (php) now, you can check "remember my decision" and you won't ever have to deal with this again, click yes, and you'll have started a fully git integrated php project in eclipse. Expand the newly created project and highlight the .settings, .buildpath, and .project files and right click on them, select Team->Ignore so that these files and directory won't be committed to any other repo. You'll see a new file (created by git) .gitignore which keeps track of these things.

http://wiki.eclipse.org/EGit/User_Guide

Topics: