Github and Pair Programming
At B2M we do a lot of pair programming. A lot of the time I am paired with James and between us we have developed several open source repositories.
Now don’t get me wrong, I love using github. It’s completely changed the landscape for developers, allowing us to demonstrate our skills by giving visibility of code and who contributed to it. One of the great features is being able to see the contributors to a repository visually for example in these graphs for the connect-cassandra I recently paired on.
Here’s the problem: git was not designed for pair programming. It only allows one comitter and optionally one author, so how do you share contributions when pair programming and sharing the same workstation?
I found some ideas on-line about doing this. The guys from Hashrocket posted an article called Pair Programming & git & github & Gravatar & You & You where they suggested creating an artificial author email address representing the pair and using that for the author in the commit. They even created a gist that does it for you. We tried this for a while, but it means that neither of the pair will show up in any of the repository graphs, only the account the changes were committed under.
The next thing I did was contact github. They were very helpful (thanks Petros) but in the end they admitted there was no current satisfactory solution. The final email points out:
“Petros: I have never tried to set up anything close to that and to be honest I am not sure if you can make it work with the contributors graph.
Roy: When we commit we want to indicate that we have both contributed equally to the code.
Petros: I cannot see how this can happen. The contributors graph works with commits that are linked to one GitHub account. Every commit you push will either be attributed to one developer or the other. They cannot be linked to two GitHub accounts.”
So What To Do?
If a single commit can only be attributed to a single developer then the only sensible approach is to alternate the users on each commit so that one of the pair is the committer, the other the author. As it turns out only the author is attributed the commit in the contributers graph.
In order to simplify this I created gits. It’s a tool to randomly chose a committer and an author before calling ‘git’. Instead of calling ‘git’ to commit to a repository use ‘gits’ instead and takes all the same command line arguments as git.
You can also force the author if one of the pair is ‘unlucky’ and missing out on their share of the commits.
This solution is not entirely satisfactory and doesn’t show the equal nature of pair programming, but in my view is an acceptable compromise. Hope you find it helpful, and any better suggestions are more that welcome.