Skip to content

Instantly share code, notes, and snippets.

@hemanth
Forked from tekkub/egit.markdown
Created September 19, 2010 12:07
Show Gist options
  • Save hemanth/586713 to your computer and use it in GitHub Desktop.
Save hemanth/586713 to your computer and use it in GitHub Desktop.

First, a warning

EGit/JGit is a reimplementation of git in java, due to this GitHub does not officially support it. Issues have happened and repositories have been corrupted by them. While it is usually a simple matter to repair these repos due to git’s distributed nature, be aware that EGit may not work as well as the official git binaries.

GitHub officially supports msysgit (openssh) on windows and precompiled or self-compiled binaries on mac and linux. The following guide was submitted by a user and may be out of date.


Another description on how to use EGit and how to upload to Github can be found in the following EGit Tutorial


Here’s one way to bring Github into Eclipse. I’ll immediately declare myself as a newbie with both git and Github. There might be smarter and better ways to do things. If you know of them, please edit this guide and correct/add as appropriate. I’ll also try to keep this guide focused on EGit. Installing Git on your OS and setting up your Github account and other issues are covered in the excellent Github guides section. Actually I think there’s not much (if anything) particular in using EGit with Github, but it’s a fitting context on this site, wouldn’t you agree? Further, I’m going to assume you’re working with a repository you can push to.

What’s EGit anyway?

EGit is an Eclipse plugin that uses a pure Java implementation of Git (JGit) to enable Eclipse projects to be controlled by a Git repository. EGit is under rapid development, I’m currently using version 0.3.1.20081024. As an Eclipse source control plugin it’s not complete yet, but it has a lot going for it and gives you some goodies and visual clues on the state of your branch.

Egit has moved to the eclipse project recently, integration snapshots are still available at the jgit.org update site mentioned below.

Installing EGit

Googling on the subject you easily get the impression that the way to install Egit is to download the source and build it yourself. But if you’re a bit more lazy than that you can add the EGit update site to Eclipse and install it like any other plugin. That’s what the JGit site suggests. That’s what I did.

Get your Eclipse project Git controlled

With the CVS and Subversion plugins I’ve used you can import a project from the source repository, and that’s what I tried to do with EGit too, but I can’t get it to work. Here’s what I do to work around that. The first step differs depending on if your uploading your project from Eclipse to Github or if your importing it from Github into Eclipse.

1a: Uploading your Eclipse project to Github

With a freshly created Github repository follow the instructions on how to set it up, except instead of making a new directory you cd to the root directory of your Eclipse project.

1b: Importing an existing Eclipse project from Github.

Import the project from Github using Eclipse’s Import feature.

Next enter the repository URL as represented on Github:

You only need to fill the URI field. EGit will parse it and fill the other fields for you. You’ll be identifying using your ssh key so there’s no password needed for the git user. Unfortunately, the EGit plugin no longer parses git@github.com URLs correctly. Make sure to choose the git+ssh protocol and enter github.com as your host, correct the path and the URL will be adjusted accordingly. The resulting URL will look like this: git+ssh://git@github.com//.git

(TODO: update screenshot!)

Then click Next and when EGit looks for the available branches it’ll ask for your ssh key pasword:

(2009/10/17 – error message: SSH2 Message – The authenticity of host ‘github.com’ can’t be established.
solution )

Then select the branch to check out and after clicking Next it’s time to choose where you want to clone the project to. Your Eclipse workspace works, but it’s not a requirement.

Then click Finish. The project won’t show up in Eclipse yet, at least not with the version of EGit I’m using. (Because of this you can also choose to clone it using command line git instead.) Here’s an important caveat and set of instructions for seemingly newer version of Egit that hypothetically allow you to import clones, but as of yet do not seem to behave normally.

Then you need to Import it into Eclipse from the directory where you cloned it to. Looks like so for a Flex project:

2: Make Eclipse aware of the project’s Gitness

OK, so you have an Eclipse project under git control, hosted on Github. But Eclipse doesn’t know it yet. Here’s how to fix that:

1. From the Eclipse project context menu choose Team→Share

2. Choose the Git repository type.

3. Select Search for existing Git repositories

Done! It’s actually very few steps, just verbosely described.

Git operations from inside Eclipse

Cool, so now you have EGit going. The project Team submenu now looks much more interesting.

As I’m not kidding when I’m saying I’m a Git newbie I don’t dare advise much on how to actually use EGit. All I’ve tried so far is Add, Commit and Push on some test projects that I own myself and where I have no collaborators.

Pushing your changes

The wizard for pushing changes is a bit confusing to me (because of my lacking Git understanding). Anyway, this works for me so far: At the first step I just click next, accepting the default repository config (should be the Github repo).

Next step is quite crowded. I guess once you’ve branched and such it’ll seem clearer. But as long as you’re working in the master branch all on your own it seems to work doing like the following pic suggests:

Hopefully I’ll get some Gitting under my belt soon enough and can get back to updating this guide some. Of course, feel invited to edit this guide with any knowledge you have on the subject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment