Created
April 25, 2013 18:55
-
-
Save rpowis/5462155 to your computer and use it in GitHub Desktop.
prepare-commit-msg git hook that adds the branch name to the end of the commit message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This hook will append the current branch name to | |
# the commit message if it's not already there. | |
ref=$(git symbolic-ref HEAD 2> /dev/null) | |
branch=${ref#refs/heads/} | |
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