Pair harmoniously with git-duet
I started doing pair programming about a year and a half ago. Since then, I've been using the same tool to set the two users involved in the pairing process.
For me, one minor issue is that authors' identity wasn't properly established because the defined author was formed with two names, "un-linked" to their real git usernames. Almost like a fictitious user.
Then, that fictitious user appears in the collaborators' statistics of the project, without the real identity of the users involved.
A few days ago, I started to use a similar tool, the git-duet gem. Built by Modcloth, this gem identifies the author as well as the committer. This way, every commit will include the real names or usernames, without the fictitious user created by merging identities, and giving credit to the people involved in the work done.
So, let's see how it works.
Installation and configuration
As any other Ruby gem:
gem install git-duet
Once installed, create the file
~/.git-authors to set the users identity, by adding names, usernames and email domain, in YAML format.
authors: ac: Ana Castro; ana-ci gv: Gilberto Villa; ingilniero email: domain: magmalabs.io
Once you start to work in pair, set the author and committer like this:
git duet ac gv
Then, when you're ready to commit, just type:
git duet-commit -m
The git log will appear this way:
And when you start to work by yourself again, use the solo command:
git solo ac
More useful commands
To set up the global git config, if you are switching between projects, use the --g/-g option:
git solo -g ac git duet --global ac gv
Also, if you tend to forget updating the pair initials (like I do all the time) or if you change your pair often, there's a git-duet tool that will remain you to update the users identities. Just add this line to your pre-commit hook (in $REPO_ROOT/.git/hooks/pre-commit)
#!/bin/bash exec git duet-pre-commit
This way, if the author and commiter are missing, the command will exit with a non-zero status. If it exits with zero status, the commit is accepted. If it exits with a non-zero status, the commit is rejected. This also happens if the identity values are stale. Of course, you can edit the staleness cutoff line in the
GIT_DUET_SECONDS_AGO_STALE environment variable (integer of seconds). 20 minutes is the default value:
export GIT_DUET_SECONDS_AGO_STALE=60 # if you work for more than a minute git commit -v # then pre-commit hook fires
You can find more useful information and commands in the gem documentation and source code. Happy pairing!