Skip to content

Instantly share code, notes, and snippets.

@philchristensen
Created December 19, 2011 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philchristensen/1497860 to your computer and use it in GitHub Desktop.
Save philchristensen/1497860 to your computer and use it in GitHub Desktop.
Append branch name to ticket
#!/bin/sh
#
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
# This hook will append the current branch name to
# the commit message if it's not already there.
branch=$(git symbolic-ref HEAD | awk -F/ '{print $NF}')
if [[ "$branch" != "master" ]]; then
grep -qa "$branch" "$1" || echo "\n(Branch: $branch)" >> "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment