Eclipse is a git with bitbucket (taming the beast)

So I find git and eclipse integration complex, ya boo, shout me down! Or is it maybe I find the way git works complex. Doesn’t matter, it’s up there as the premier repository so the challenge must be taken. Having recently been introduced to bitbucket and how scary it feels when your hard drive has just died it’s time to take the matter seriously. For my sins, my biggest ongoing project is written in Java, I use eclipse as the IDE and I, cough cough, haven’t subjected, I mean submitted the 12,000 or so lines of code to a repository. Yes I take regular (when I remember) backups to various places, Dropbox, Google and am thinking of trying JustCloud and actually paying for storage. But first let’s make use of that Bitbucket account that was created as a result of a colleague sharing a Ruby on Rails project with me – which I still haven’t assimilated properly, another on the to do list.

So here’s the setup: I’m starting with Eclipse Juno Service Release 1 (as per the About Eclipse dialogue box, Mac OS X 10.8.2 btw), and copied the project to another in the workspace, called DrumScoreRepTest.

Looking at existing blogs and links out there, loads of good info, and here I’m documenting a straight process for getting it all set up and working in a certain way, i.e. to suit the individual developer looking to make sure their code isn’t just on a usb drive in their house.

There are a number of discrete pieces of work to get set up:

  1. Installing Git on your development machine
  2. Creating your Bitbucket setup
  3. Integrating your development process

I’m being quite verbose as I’m going through as I found reading other blogs and articles that because I was new to Git and some of the concepts and terms I found I needed a lot more background info as part of my learning process.

Integrating Git on your development machine

Time to add it to Eclipse then.

Add the Egit plugin site to the list of places Eclipse knows about to search for software. From the Preferences menu option:


Then from the Help menu choose Install Software as per below, and step through the wizard.


Eclipse will restart. Next step is to put the project into Git:

  1. Open the project in Eclipse
  2. Right click on the project name
  3. Select Team -> Share Project

Next Eclipse asks which repository plug-in to use to share the project, choose Git and you’re presented with the following dialogue box:


At this stage we need to create a repository in which to track our code, use the Create… button. Accept the default location, and make sure the checkbox that talks about creating the repository in the parent folder is unticked, i.e. clear. We do not want the repository to exist within the eclipse working directory, as that get’s confusing as you would need to tell Egit to not try to put it’s own repository files in the repository (recursively protect itself anyone?).

The default location for me is /Users/alan/git, and the repository name chosen is reptest1, you then end up with the project name tagged with the repository name and the mysterious git phrase NO-HEAD, let’s not delve into that now, plenty git references out there.


So having now got the project under Egit control, and associated it with a repository, it’s time to get the current files in the project baselined in the repository. This is achieved by right clicking on the project name above, selecting Team -> Add To Index, a dialogue box flashes by that is too swift to see and the view of the project in the Eclipse Package Explorer changes subtly.


Note how the question mark planted over the folder icon has been replaced with a *. This means there are files in the folder which have been added as being under git tracking, but not yet committed. The act of committing will effectively create the committed baseline of our app in the repository. Everything we do after the commit is a change we check back in as needed.


Apologies if the screen shots are slightly different in size from the previous, I’ve upgraded to a retina screen Mac in the middle of writing this but am doing my best to scale it back to where I started.

Anyway you can now see this is all checked in as the master. Just to exercise the git plugins I deleted the last 3 files, dg.tar thru manifest, performed a commit using the Team -> Commit menu (right click over the project name), and then using the Eclipse history view you can see this activity.


Creating your Bitbucket setup

Create Bitbucket account

Create SSH credentials – kinda hard to document it better then here

Make sure Eclipse knows about them by checking at Eclipse -> Preferences -> General -> Network Connections -> SSH2. It should show Eclipse has already picked up your defaults. Don’t worry about the Bitbucket host not appearing in Known Hosts, it will put it there in following stages.

Push your local repository up to Bitbucket to be the master shared repository by creating an empty repository on Bitbucket, choose the option to import code. BitBucket then gives you the git commands to run at the shell – we’re not using the shell here, but need the information displayed to provide toe Eclipse. Switch to Eclipse and right click on the project name and choose Team -> Remote -> Push from the drop down menu.

In the first screen provide the ssh command form the Bitbucket


Choose the Add all Branches Spec button in the middle of the dialog box and it populates as shown below.


Choose Finish and Eclipse processes the local Git repository, and uploads it to the Bitbucket and you should end up with the screen below.


Switch back to the Bitbucket window, choose your repository and you see the history, showing the upload of your repository and any commits.


Integrating your development process

This is actually a fairly important part of understanding what we’ve done here. There’s many different ways to use all these technologies depending on how you want to work. All the set up here is based on use of the centralized workflow from as the model for single developer.

As all I want to make sure is I’ve got my code assets out there and protected

TO BE CONTINUED …. miserable Scottish rain again today but it’s Sunday so family stuff