One good reason why Git makes sense

When I first heard about distributed version control systems and Git about a year and a half ago, I was very much a Subversion user both at work and at home. I knew how to setup Subversion, it’s ACLs and make it available over http via Apache. You could say I was committed (pun intended). And then all this noise about DVCS and in particular Git and I was wondering why in the world would anyone give away control over their code repository. If I wanted to work disconnected from the network (say on the airplane like everyone seemed to want) I would just work and worry about checking things back in when I connected to the network next.

In spite of being a non-believer I stayed with Git and what seemed like the hype around it. I read up on it and I even got myself an account on github and setup a few projects there. Git seemed interesting but it wasn’t really solving any problems for me that Subversion wasn’t already. And then I had my first ah ha! moment yesterday.

So I was building out a new application at work where we use Subversion. Instead of checking in the initial project skeleton into Subversion like I normally would’ve I did a git init on the project and decided to use git till I was ready to commit it to Subversion (btw stay tuned for how easy this is in a later post). I noticed with Git I was committing much more frequently and much smaller changes. Probably because I knew that when I was ready to push the code to Subversion and share it with the rest of the team I could easily collapse my commits. This is nice but not my ah ha! moment yet.

After one such frequent git commit, I started working on a new feature and half way through realized I didn’t want to go that route and needed to implement it differently. But I didn’t want to lose all the things I put in place for this feature if I ever needed to come back to it or to refer to it in the future. And so here it comes – I used the git stash command to save away my uncommitted changes and revert my working copy back to the last commit. So now I had a fresh starting point and I also had all the work that I’d done saved away for the future if I needed it. I could not imagine doing this in Subversion as easily having to deal with it in the past. You could use branches in Subversion but it is a much more heavy weight solution for this.

So there you go, my first Git ah ha! moment.