A problem is that the commit you are on (detached from the head) may
actually be on several branches. If you only want one branch to
be presented, you'll have to figure out some way to choose between them.
But if you're happy seeing all the branches (with hashes) that contain your
current commit you can say
git branch -v --contains HEAD
Here's some example output:
* (detached from 0bc85ab) 0bc85ab Git 1.9.2
master cc29195 Git 2.0-rc0
you could trim that with grep and/or awk.