I need a command which returns the full reference name of my currently checked out revision. Or as close to this as possible. Big plus if git-only (for cross-platform purposes).
By "full reference name" I mean e.g. refs/tags/my-tag, refs/heads/my-branch.
Examples:
git checkout master
magic command
# => /refs/heads/master
git checkout v1.0.0
magic command
# => /refs/tags/v1.0.0
git checkout 86742545e8152a8fbf31eafa55eb573042f61f5d
magic command
# => 
Few points of reference:
- I actually don't think this is possible with 100% accuracy because (as I understand git) there's no difference between checking out a tag and a specific hash. I.e. .git/HEADshows the hash in both cases.
- git show-refshows all references and the corresponding commit hashes
- git symbolic-ref HEADworks for branches and with the- -qoption it doesn't fail if you're not on a branch
- git describe --tags --exact-matchkind of works for tags, but you'd need to prefix it with- refs/tagsand get rid of stderr
Related:
All I could find seemed too complicated for what I'm looking for.
 
    