If you're using a detached HEAD but there is a branch pointing to the same commit as HEAD, here was the only method I found that would work to find a branch and properly ignore tags.
git for-each-ref --format="%(refname:short)" --points-at HEAD refs/heads
The refs/heads
filter is to only list local branches, and excludes remote branches as well as any tags.