Reputation: 1494
Locally I can check what all tags are available to use by command git tag, now if I need to know which tag is being used locally, what command I need to use.
Upvotes: 1
Views: 1585
Reputation: 793
The following referred here by M K should give the current tag been checked out:
git describe --tags --abbrev=0
Upvotes: 0
Reputation: 60393
To find out all the tags and branches that refer to the checked-out commit,
git show --decorate
and you can of course tailor what else it displays with e.g. -s
and --oneline
... there's an endless variety of details you can choose.
If there are multiple tags pointing at the current checkout, you have to consult the reflogs to see which was used to get there. For example, to find out what reference was used to get the current checkout and what's been done since,
git reflog | sed '/checkout: moving from/q'
Upvotes: 1
Reputation: 20564
I guess you would like a command that returns the tag name of your currently checked out commit if it is tagged.
You can write this:
git tag --list --points-at=$(git rev-parse HEAD)
git rev-parse HEAD
shows the commit hash of the checked out commit
git tag --list --points-at={commit-id}
prints the tag pointing at a specific commit.
Note that this command might return nothing, if the currently checked out commit is not tagged
Upvotes: 1