I have a commit template set up for git, and I would like to include the name of the current branch in it. I usually set up the branch to be the bug id, and it would help me
Just cobbling together the comments from Jefromi's answer, I end up with something like this. Surely it could be tighter (if I knew what I was doing):
tempFile='/tmp/git-commit-template'
git config commit.template "$tempFile"
rm $tempFile
branch=$(git symbolic-ref HEAD|sed s#refs/heads/##) exec 3<> "$tempFile" && awk -v TEXT="[$branch]" 'BEGIN {print TEXT}{print}' "$tempFile" >&3
git add .
git commit -a