If a Git commit hash has multiple tags associated with it and/or is the head of multiple branches, is there a good way to list all of them?
I've looked through the options to git name-rev
, git describe
, and git symbolic-ref
but haven't found any options that seem to do what I want. Frustratingly, git name-rev
has a --tags
option to list only tags but no apparent mechanism to list only branches (and git name-rev
always seems to prefer tags over branches for me anyway).
$ git checkout -b branch1
$ git checkout -b branch2
$ git tag tag1
$ git tag tag2
$ git name-rev HEAD
HEAD tags/tag1
$ git describe --all HEAD
HEAD tags/tag1
$ git symbolic-ref HEAD
refs/heads/branch2
To map a commit hash to all of its symbolic names, will I need to run git tag --list
and git branch --all --list
and then run git rev-parse
on all of the results?