I’m having trouble finding out which tag is currently checked out.
When I do:
git checkout tag1
git branch
I can’t seem to find out which tag I’m on. It only logs:
* (no branch)
master
Is it possible to find out which tags are checked out? In the above example, this would be tag1.
Edit
Jakub Narębski has more git-fu. The following much simpler command works perfectly:
(Or without the
--tagsif you have checked out an annotated tag. My tag is lightweight, so I need the--tags.)Original answer
Someone with more git-fu may have a more elegant solution…
This leverages the fact that
git-logreports the log starting from what you’ve checked out.%hprints the abbreviated hash. Thengit describe --exact-match --tagsfinds the tag (lightweight or annotated) that exactly matches that commit.The
$()syntax above assumes you’re using bash or similar.