Pankaj Kumar Katiyar
Pankaj Kumar Katiyar

Reputation: 1494

Is there any way to check which git tag is deployed or being used?

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

Answers (3)

Raymond A
Raymond A

Reputation: 793

The following referred here by M K should give the current tag been checked out:

git describe --tags --abbrev=0

Upvotes: 0

jthill
jthill

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

edi9999
edi9999

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)

Explanation:

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

Related Questions