Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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