So my branch is named after bugtracker ticket number, something like \"issue-1234\", and we have a convention to always write down ticket number in commit message. I\'m wond
This way you can add branch name to the start of commit message. It's prepare-commit-msg hook. Work both for "git commit -m" and "git commit" commands. The option is file .git/hooks/pre-commit.skip which contains a list of branches you don't want to auto-prepend.
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
FILE_CONTENT="$(cat $1)"
skip_list=`git rev-parse --git-dir`"/hooks/pre-commit.skip"
if grep -E "^$BRANCH$" $skip_list; then
exit
fi
if [ $2 = "message" ]; then
echo $BRANCH: $FILE_CONTENT > $1
else
echo $BRANCH: > $1
echo $FILE_CONTENT >> $1
fi