Skip to content

Instantly share code, notes, and snippets.

@dialex
Last active June 24, 2020 14:52
Show Gist options
  • Save dialex/68b56e903cb1389b03f5940e1d169aa5 to your computer and use it in GitHub Desktop.
Save dialex/68b56e903cb1389b03f5940e1d169aa5 to your computer and use it in GitHub Desktop.
co-author commits
#!/bin/bash
# How to use this little dev tool
#
# You need to add the following snippet to .git/config
# [commit]
# template = .git/.gitmessage
#
# And this is how you should run it
# ./pair-with.sh will simply empty the .gitmessage file
# ./pair-with DM will create this content:
# Co-authored-by: Daniel Moor <[email protected]>
# It is also possible to add multiple developers as co authors at the same time:
# ./pair-with XY AB MN
function co_author() {
user=$1
echo "Co-authored-by: $user" >>.git/.gitmessage
echo "Now pairing with $user"
}
echo >.git/.gitmessage
while [[ $# -gt 0 ]]; do
case $1 in
XY)
co_author "Name Surname <[email protected]>"
shift
;;
*)
echo "Unknown user: $1"
shift
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment