Archive for the Category windows

 
 

Getting started with Git, Github and Eclipse on Windows

Having got github and eclipse talking to each other in OS X and Ubuntu I thought that doing the same in windows would be pretty straight forward. Unfortunately, I quickly ran into the mess that is ssh handling on windows. In the future I’ll post about getting git to work from cygwin and from the dos prompt, today I’m going to concentrate on getting eclipse to handle everything. This won’t get you the great command line but it will get you started. So let’s get started.

Install git eclipse plugin

The eclipse integration relies on the egit plugin. To read more about the project visit http://www.jgit.org/.
To install the plugin add the update site

http://www.jgit.org/update-site

Once you’ve added the update site open it and you’ll see that there are several builds available. I’ve been using the Release Build which seems to work well although the best option is likely to change. Check the box for the Release Build and hit install and follow the wizard.

Get started with github

ssh setup

Eclipse has it’s own setup for ssh key management.
Open up the ssh management in Preferences => General/Network Connections/SSH2.
Open the “Key Management” tab.
Click “Generate DSA key…”. This will generate your ssh key which is now shown to you in the ssh2 tab
Click “Save Private Key…”
Click “OK” to ignore the warning about saving without passphrase protection
Click “Save” with the default location to store the keys in your ssh directory
You now have ssh keys setup for use with eclipse
Copy the key into your clipboard from where it is displayed on the ssh2 tab, you’ll need this for the github signup.

Create account

Go to http://github.com/plans and signup to whichever plan you want. On the signup screen there is an area to add your ssh key. You should have this in your clipboard buffer from the previous step. You can now paste it into the github signup form.
Once you’ve finished the signup screen you’ll be logged in and taken to your github home.

Create repository

On the github home screen, next to “Your Repositories” click “create a new one”
Once you’ve filled the form out hit “Create Repository” and you’ll be taken to a page with some initial instructions. Follow these and you will end up with a local repository that is pointing to github as the origin.

You’re now setup with a github account and your first repository. So all that’s left is the eclipse setup.

Checkout from github

The egit plugin assumes that you haven’t checked out the project yet so if earlier you checked out your new repository into your workspace folder you need to delete it so that egit can check it out itself and manage it. If anyone has found a better way of doing this please let me know.

From the “File” menu select “Import”
Select Git/Git Repository
You now need the git address for the repository you created in github.
To get this visit http://github.com
Click on your repository under “Your Repositories”
Copy Your Clone URL:
Back in eclipse paste into the import wizard
Change protocol to git+ssh
Hit next three times and eclipse download your repository
You’ll then arrive at the Import Projects screen. At this stage your project has already been checked out onto the filesystem at path/to/workspace/project_name.
If you repository is currently empty then the list of projects will be blank
Egit will only checkout projects that have been previously been set up in eclipse
To remedy this we need to manually add a .project file to the root of your project
Using your favourite text editor create a file at path/to/workspace/project_name/.project

Paste in the following - changing the name to the name of your project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Once you’ve saved this return to eclipse and in the import wizard hit back and then next. When the projects screen is shown you should now see your project listed.
Hit finish and you should now see your project checked out in your workspace

OK, you’re now ready to start using your git repository from inside eclipse. For now there’s no command line git setup, my next two posts will be about getting git setup with cygwin and with the dos prompt.