George Sovetov George Sovetov - 3 months ago 28
Git Question

Git: how do I find tags pointing to specific revision?

Given some revision, say

, I need to find tags pointing to it.

I can do that with
git show-ref --tags | grep $(git rev-parse $REV) | awk '{print $2}'

Is there special command for it? (That works on Windows too.) Maybe there is even back reference mechanism in Git...



To list tags pointing to a given commit use the following command:

git tag --points-at commit

git tag --contains isn't a correct answer to this question, since it also includes later tags from which the specified revision is reachable.

git tag -l --contains $REV

From git tag documentation:

-l <pattern>, --list <pattern>

List tags with names that match the given pattern (or all if no pattern is given).

--contains [<commit>]

Only list tags which contain the specified commit (HEAD if not specified).