Skip to content

Instantly share code, notes, and snippets.

@manderly
Created February 9, 2015 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save manderly/18b0e0fab0198423615c to your computer and use it in GitHub Desktop.
Save manderly/18b0e0fab0198423615c to your computer and use it in GitHub Desktop.
Git hook: Automatically add branch name to the end of every commit message
# Automatically adds branch name to the end of every commit message. Handy for git/JIRA integrations.
# Make a copy of .git/hooks/prepare-commit-msg.sample in your repo and name the file prepare-commit-msg (remove "sample" extension)
# Paste the following into the file, save the file, and try it out in bash
NAME=$(git branch | grep '*' | sed 's/* //')
echo $(cat "$1") "$NAME" > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment