コメント用フックのprepare-commit-msgに下記のように書けばできる。
$ cat .git/hooks/prepare-commit-msg
#!/bin/sh
if [ "$2" == "" ] ; then
mv $1 $1.tmp
echo "`git branch | grep "*" | awk '{print "[" $2 "] "}' `" > $1
cat $1.tmp >> $1
fi
$
※エディタを使ったcommitの場合に$2が空で来るらしい
$ cat .git/hooks/prepare-commit-msg
#!/bin/sh
if [ "$2" == "" ] ; then
mv $1 $1.tmp
echo "`git branch | grep "*" | awk '{print "[" $2 "] "}' `" > $1
cat $1.tmp >> $1
fi
$