Created
June 26, 2017 10:51
-
-
Save abbasadel/ff03536b35b36ce9953c6f6a879563e8 to your computer and use it in GitHub Desktop.
Git hook to prepend branch name to 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 | |
## source .git/hooks/prepare-commit-msg.samlpe | |
BRANCH=`git branch | grep '^\*' | cut -b3-` | |
FILE=`cat "$1"` | |
echo "$BRANCH: $FILE" > "$1" | |
case "$2,$3" in | |
merge,) | |
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; | |
*) ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment