Git as a productivity mindhack

Aug 30, 2009

Git is a well-known source code management tool. It enables you to keep versioned copies of your source code, leaving a historical audit trail of your edits over time. It also supports branching - creating two or more divergent versions of your code that may proceed off in different directions. It also supports lots more cool stuff, but for the purposes of this post, these are the only features that matter.

For a long time, I’ve heard lots of positive stuff about Git (there’s even a whole site devoted to this) without really appreciating the points being made. At work, we use Git for basic source code management, but 95% of what we use it for is simply for keeping a history of what was edited and when. In short, I’ve never really got the best possible use out of SCM/version control systems. My standard practice has been to start a repository at the beginning of a project, and progressively commit more changes until the project is finished. If I need to copy code between projects, or create a new project based off an old one, I’ll often take the lazy way and just physically copy the files and create a new repository.

What follows is an anecdote of how using version control properly has made me more productive. If you habitually use version control and have done for years, you might find little of value in this.

As a background, I should explain that my biggest challenge as a software developer is getting things finished. On almost any project, there are myriad ways of doing things, many of which are more interesting than the challenge of creating working software. And yet working software is often what people want, and there’s a certain satisfaction that comes from delivering software that cannot be had by any other means. Getting to the end of a project is a long-term reward; experimenting with cool stuff is near-instant gratification. All too often, instant gratification wins. (At this point I should point out that a certain amount of experimentation is healthy; it’s only by trying new things that we learn. However, by completing projects you open up a whole range of new options for experimentation, often more fulfiling than those you began with).

I recently experienced this problem when working on some code for Wisdom Hive. This is a part-time project for me and, as such, it’s very tempting to use it as a testing ground for new ideas. The problem I was having was that I was tying myself in knots, constantly revising my code in a perfectionist quest to find the best way of doing things. It was a classic case of premature optimisation. Again, it was not without value - I’ve learned a lot about concurrency, distribution and scalability from the practical research I’ve done into it. But it wasn’t necessary for creating working code.

The solution to my problem turned out to be extremely simple. Having realised that I could either write simple code that worked or write complex code that worked even better, I simply set up a new branch of the project for experimental stuff, and decided to write the simple code for the main branch. For some reason, something clicked in my brain. I could now write code very quickly and with minimal fuss for the main branch, safe in the knowledge that, if I wanted to try something out, I could do it on the experimental branch. I could even create more branches for different experiments. What changed from before was that I stopped thinking of the version control system as simply being “where code goes after it has been written” and started to think of it as a tool in the process of development itself. I can now have multiple versions of my code, all behaving differently, allowing me to quickly experiment with a new idea with minimal commitment. My perfectionist anxiety is gone, allowing me to create simple working code for the master branch, meaning that I get things done much more quickly.

I realise that this is probably an obvious notion to many people. But for me, it has helped me to overcome one of my most annoying personality traits in order to become more productive, so I’m posting about it in the hope that others might benefit from a similar approach.