gitgit-checkoutgit-tag

Show which git tag you are on?


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.


Solution

  • Jakub NarÄ™bski has more git-fu. The following much simpler command works perfectly:

    git describe --exact-match --tags
    

    Or without the --tags if you have checked out an annotated tag. My tag is lightweight, so I need the --tags.