Working with Remote Branches on GitHub

Yesterday I wanted to contribute a patch to add support for the decimal type to NoRM – the new LINQ enabled provider for MongoDB that Andrew Theken, Rob Conery, Olivier Oswald, Steve Mason and a bunch of other guys are working on. Even tho I’ve been using GitHub as my personal Version Control System for the past couple of months – this was my first experience of trying to work on a collaborative project hosted on Git. The wonderful thing about Distributed Version Control Systems is that you can pick which fork you want to work from. On my current development machine – I only have vs2010 RC on it – and luckily on the NoRM project Oliver Oswald forked the codebase and created a branch with a vs2010 solution file. You can see this forking action on the network graph on GitHub:

You can see from the screenshot that ooswald forked atheken’s master branch and created a vs2010-unstable branch which I then forked to develop my decimal patch. The problem I encountered was that when I created a local copy of the remote repository I was actually seeing the version of atheken’s master. At this point I realised I was absolutely out of my depth and decided to take a couple of hours to watch the exceptionally good Mastering Git series on TekPub. Although it gave me a much better understanding of Git and made me realise that I must somehow bind a local branch to a remote branch. After a little googling I realised that what I needed to do was checkout and track the remote branch using the following command in the Git Bash:

git checkout –track -b vs2010-unstable origin/vs2010-unstable

This worked a treat and allowed me to make my changes then push my changes back to the origin. Took a whole lot of learning, but quite simple once you know how.


About this entry