Skip to content

Instantly share code, notes, and snippets.

@abbasadel
Created June 26, 2017 10:51
Show Gist options
  • Save abbasadel/ff03536b35b36ce9953c6f6a879563e8 to your computer and use it in GitHub Desktop.
Save abbasadel/ff03536b35b36ce9953c6f6a879563e8 to your computer and use it in GitHub Desktop.
Git hook to prepend branch name to commit message
#!/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