如何列出指向git中特定提交的所有标签 [英] How to list all tags pointing to a specific commit in git
问题描述
我见过命令 git describe
和 git-name-rev
但我没有设法让它们列出多个标签.
I have seen the commands git describe
and git-name-rev
but I have not managed to get them to list more than one tag.
示例:我有 sha1 48eb354,我知道标签 A 和 B 指向它.所以我想要一个 git 命令 git {something} 48eb354
产生类似于A,B"的输出.我不想知道与其他标签或分支相关的引用只是标签的完全匹配.
Example: I have the sha1 48eb354 and I know the tags A and B point to it. So I want a git command git {something} 48eb354
that produce output similar to "A, B". I am not interested in knowing references relative other tags or branches just exact matches for tags.
推荐答案
git show-ref --tags -d |grep ^48eb354 |sed -e 's,.* refs/tags/,,' -e 's/^{}//'
应该适用于轻量级和带注释的标签.
should work for both lightweight and annotated tags.
这篇关于如何列出指向git中特定提交的所有标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!