git-pair
git-pair copied to clipboard
Git plugin for pair programming
Git for Pair Programming
Git commits can only have one author. However, there is a convention that
multiple authors can be recorded by lines beginning with Co-authored-by: at
the end of a commit message. This convention is now supported by
GitHub
so all the co-authors can share the internet points.
This POSIX shell git plugin makes it easy to manage pair programming sessions
and automatically add the appropriate Co-authored-by trailers to your commit
messages.
Installation
- Put the
git-pairscript somewhere in your$PATH. - Put the
prepare-commit-msgscript in.git/hooks/inside each of your repos.
That last step is a bit tedious. I suggest you create a shell alias like so:
alias git-pair-init="cp /somewhere/prepare-commit-msg .git/hooks"
Usage
$ git pair add rh "Robin Hood <[email protected]>"
$ git pair add mm "Maid Marion <[email protected]>"
$ git pair add ft "Friar Tuck <[email protected]>"
$ git pair add lj "Little John <[email protected]>"
$ git pair list
rh Robin Hood <[email protected]>
mm Maid Marion <[email protected]>
ft Friar Tuck <[email protected]>
lj Little John <[email protected]>
$ git pair show
No pairs currently set.
$ git pair set mm ft
$ git pair show
Maid Marion <[email protected]>
Friar Tuck <[email protected]>
$ git commit -m 'Something informative'
Committing with co-authors:
+ Maid Marion <[email protected]>
+ Friar Tuck <[email protected]>
[master d898f8d] Something informative
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
$ git log -n1
commit d898f8d3d83759843d19bf71b78ce6089929ccce (HEAD -> master)
Author: Your Usual Git Username <user.email@gitconfig>
Date: Sat Oct 27 14:17:30 2018 +0100
Something informative
Co-authored-by: Maid Marion <[email protected]>
Co-authored-by: Friar Tuck <[email protected]>
Notes
The list of possible authors is stored in your global ~/.gitconfig. The list
of currently active authors is stored in the local .git/config of your current
repo. This way you can have different authors active in different repos at the
same time, but you can share their contact details across all repos.
Although git pair add will always add to ~/.gitconfig, the list of possible
authors is actually read from all your git configs: so a system administrator
could pre-populate a list of possible authors to be shared by all users by
putting them in /etc/gitconfig.