Based on this question I made a git hook prepare-commit-msg
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //') 
DESCRIPTION=$(git config branch."$NAME".description)
echo "[$NAME]"': '$(cat "$1") > "$1"
if [ -n "$DESCRIPTION" ] 
then
   echo "" >> "$1"
   echo $DESCRIPTION >> "$1"
fi 
It works pretty well on simple commits. Example - [issue14020]: some text message if commit was made in issue14020 branch.
But then I make a rebase I have got message like this [(no branch)]: [issue14020]: some text message. Is there any way to skip this "no branch" part?
 
     
    