Skip to content

Instantly share code, notes, and snippets.

@sshine
Last active September 26, 2022 17:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshine/d5a2986a6fc377b440bc8aa096037ef0 to your computer and use it in GitHub Desktop.
Save sshine/d5a2986a6fc377b440bc8aa096037ef0 to your computer and use it in GitHub Desktop.
Commit under pair-programming
#!/bin/sh
#
# Install into e.g. ~/bin/git-co-commit
#
# Yes, this creates a 'git co-commit' sub-command even though the binary is called 'git-co-commit'.
case "$1" in
"--halp")
cat <<EOF
Usage: git co-commit --halp
Usage: git co-commit [--person] ...
EOF
exit 1
;;
"--alan")
coauthor="Alan Szepieniec <alan@neptune.cash>"
;;
"--thor")
coauthor="sword-smith <thor@neptune.cash>"
;;
"--simon")
coauthor="Simon Shine <simon@neptune.cash>"
;;
"--einar")
coauthor="Einar Rasmussen <einar@neptune.cash>"
;;
"--ferdinand")
coauthor="Ferdinand Sauer <ferdinand@neptune.cash>"
;;
*)
echo "Please specify --person!"
exit 1
esac
shift # ditch $1
git_path="$(git rev-parse --show-toplevel)/.git"
commit_template_path="$git_path/coauthor-commit-template"
echo -n "\n\nCo-authored-by: $coauthor\n" > "$commit_template_path"
git config commit.template $commit_template_path
git commit $@
git config --unset commit.template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment