Wednesday, 4 November 2009

Get Eclipse, EGit and github all working together on OSX

I've managed to get all the pieces working for this. It's not an especially neat solution, but I should be able to give you enough information to enable you to create a project in github, install and configure EGit and then import the project.

Creating a github account

If you don't already have a github account, start here:

Fill in your username, email address and password (you can ignore the public key right now if you like) and hit submit to go to your dashboard.

Create ssh key and test your connection to github

These instructions are for OS X, although Linux users will probably be able to follow these instructions closely, there are instructions for all operating systems at Probably the link marked Generating SSH Keys is the place to go first.

The notes for the section below are discussed in detail at

Open the terminal and type:

The default file location will probably be something like: (/Users/%your_username%/.ssh/id_rsa) and then it will ask you for a passphrase.

To copy your key to the clipboard:

You can now go to your github accpunt page and select "add another public key" to paste your public key into the textarea.

You should now be able to confirm everything works by testing the following:

Once you've entered your passphrase, you should see a message saying something like: "You've successfully authenticated, but GitHub does not provide shell access".

Create a config file for the EGit plugin

In the terminal

and create a file called config containing the following line:

Installing EGit

I'm guessing you already have Eclipse installed at this stage;

Go to Help > Install New Software and select Add to add a new site:

Add this as the location

And select the Plugin, then Next, then restart when Eclipse prompts you to.

Create a github repository

On your github home page, you can now create a new repository, give it a name, fill in the details and when done, you should see your Clone URL - should look something like this:

There will be a link next to it to copy it to your clipboard.

It will also provide step-by-step instructions for you to install and configure git, check out the project and make the first commit. Once this is done, you should be able to work with the project within EGit.

At the install stage, you may need to execute the script "setup PATH for non-terminal" by selecting Open With, Other, select Enable All Applications, then go into Utilities and select terminal. Close all instances of the terminal and reopen, you should now be able to use git from the terminal.

Import the repository into Eclipse as a project

I used this as a starting point and would highly recommend you check it out if you want a more visual walk-through of the steps involved:

Right click on the project Explorer, select Import, expand the Git folder and select Git Repository and next.

Paste your Clone URL into the First field (URI) and it should complete most other fields for you.

Change the protocol to git+ssh and do not enter anything for the Authentication section (leave the User pre-filled as "git").

If everything is set up properly, you should get a prompt for a password - this is your passphrase from the earlier stage.

It should now locate the master branch you created when you followed the "Next Steps" section. Select it if you need to, then select Next. As there are no eclipse files in the project, uncheck "import projects after clone" and Finish.

Right click on the Project Explorer, New > General > Project, give it the same name as your repository. It should "create" your project in the Project Explorer (you should now see the README you created and committed).

Right click on your project folder in the Project Explorer, select "Team" and "Share Project". Select Git as the repository type and then next. Highlight your project and select Finish.

You should now be able to open the README in eclipse, make a change, save it and commit your changes.

Other related reading:

1 comment:

Ken Pierce said...

I had the repository all set, it was the import step that was messing me up. This blog post solved my very frustrating several hours (over several days) set up problem. Thanks so much.