Skip to content

Instantly share code, notes, and snippets.

@vsshs
Forked from manderly/prepare-commit-msg
Last active December 11, 2015 12:07
Show Gist options
  • Save vsshs/8a59b29e3b7e116b08d5 to your computer and use it in GitHub Desktop.
Save vsshs/8a59b29e3b7e116b08d5 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") " in branch: $NAME" > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment