I love Git. I can’t believe I ever loved another version control system. Recently I’ve started using Git branches to keep one particular lot of changes out of my master repository. I wanted to upgrade my current VS solution and projects to VS 2010 Beta 2, use VS 2010 to add features to the code base, then only check in the non-VS 2010 related changes. That way my fellow developers don’t have to worry about the slightly different .csproj
files and we can all work together happily. :)
Now the changes made by the VS2010 upgrade wizard are very minor – basically just updating the ToolsVersion
attribute to 4.0 and providing a fallback OldToolsVersion
element set to 3.5.
So here’s what I did. The first step was to create a branch off my master using git checkout -b vs_upgrade
. I then ran the VS 2010 upgrade wizard which changed the relevant files, then commited those to my vs_upgrade
branch. Second step was to create a branch off my vs_upgrade
branch to add my feature (not strictly necessary, but keeps things nicely separated). I can now happily make changes to the code and commit the new feature to my feature branch. The structure now looks something like this:
Now I need to get my feature back into my master
branch, minus the VS 2010 upgrade. We can just cherry pick the change we want (I use gitk --all
rather than the command line) and apply it to the master
branch. Now we can push master
to our remote server and everyone has the change, minus the VS 2010 bits. Very cool!
We can rebase our vs_upgrade
branch whenever some new changes are applied by other developers to master
, and we get back to our first picture. We always have just a single commit containing our VS-related changes (so we don’t have to repeat the upgrade), and we can always just cherry pick the changes we want made on top of the upgrade and apply them to our master. I get to play with VS 2010 and the nightly builds of ReSharper 5.0, without having any effect whatsoever on my team mates using VS 2008. The ease with which Git handles this branching and any merging is just awesome! :)