Skip to content

Instantly share code, notes, and snippets.

@asabirov
Last active August 29, 2015 14:01
Show Gist options
  • Save asabirov/9f40e3d280ee7ad633db to your computer and use it in GitHub Desktop.
Save asabirov/9f40e3d280ee7ad633db to your computer and use it in GitHub Desktop.
Git hook which appends current branch name to commit message (.git/hooks/prepare-commit-msg)
#!/bin/sh
BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT=`grep -e "^[^#]" $1`
if [ -z "$CURRENT" ]
then
NEW_MSG=$(echo "$BRANCH"; cat "$1")
echo "$NEW_MSG" > $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment