Pair programming, which is a common practice in modern software teams, means two people are responsible for the work developed. But all the commits in Git's history are normally only in one persons details.
By attributing both pair members praise (and blame ;p) and most likely future questions can be directed to both, instead of just the owner of the machine it was developed on.
As Git does not support this out of the box, there are several work-arounds:
Alternate commits between the members randomly or in alternate order.
Use the separate author and committer git settings to split attributions. E.g.:
There are many alternative tools to accomplish this:
Merging the both pair members as one committer means combining both names as one, and a still valid email address that represents both members. E.g.
GIT_COMMITTER_NAME="Sue Jones and John Smith"
As you can see the merge option combines the names and appends the email alias with a + separating. This makes it a valid email address which is still Sue's as all mail servers will ignore what is between + and @.
The scripts are available as a Ruby Gem:
gem install pivotal_git_scripts
You may need to sudo this command if root privileges is required.
Create a ~/.pairs file.
# .pairs - configuration for 'git pair'
# <initials>: <Firstname> <Lastname>[; <email-id>]
js: John Smith; john.smith
sj: Sue Jones; sue.jones
aw: Alun Wilson; alun.wilson
# no_solo_prefix: true
If prefix is not empty it will prefix emails with its value. E.g. in the above devs will result in:
So that all emails will end up in email@example.com, which may be an alias for the whole dev team. A blank prefix may be preferable so that the email addresses generated are sent to at least one of the pair. (The pair order is alphabetic)
If global is true, this will set these values globally across all git repositories on your machine. Using the --global option will do the same.
Alternatively create another script that loops around an environment variable of projects or root folder to pair on.
If John and Alun are pairing on a project then use their initials with Git pair:
git pair js au
The pair has now been set up.
git config user.name
GIT_COMMITTER_NAME="Alun Wilson and John Smith"
git config user.email
All commits in this project will now be attributed to Alun and John.
echo blaaaaah > aha.txt;
git add aha.txt;
git commit -m "paired";
git show --name-status
Author: Alun Wilson and John Smith <firstname.lastname@example.org>
Date: Wed Feb 29 20:36:33 2013 +0000
At the end reset back to just yourself (John Smith) with:
git pair -u;
git config user.email
You may want to create a git alias like git solo to accomplish the same thing.
If you want to have commit history to be real people and only one person per commit, then you can instead use:
This does not merge the details but chooses a pair member randomly to be the committer.
You might create morphed or merged avatars from both members photos.
Please fork and send a pull request for to correct any typos, or useful additions.
Otherwise contact flurdy. Especially for things factually incorrect. Apologies for procrastinated replies.