Git能够检索仅存在于特定分支中的标签列表吗? [英] Is it possible with Git to retrieve a list of tags that exist only in a certain branch?
本文介绍了Git能够检索仅存在于特定分支中的标签列表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道在Git中是否有可能检索标签列表(很像 git tag
命令的结果),但列表应该是有限的只有到某个分支。
I would like to know if it's possible in Git to retrieve a list of tags (much like the result of the git tag
command), but the list should be limited only to a certain branch.
如果这是可能的,任何人都可以解释这是如何完成的?也许有一些模式匹配的魔法?
If this is possible, can anyone explain how this is done? Perhaps with some pattern-matching magic?
推荐答案
我认为这会做你想做的:
I think this will do what you want:
git log --pretty='%H' <branch> |
xargs -n1 git describe --tags --exact-match 2>/dev/null
它使用 git log
获取分支中的提交列表,然后将它们传递给 git describe
以看看他们是否对应一个标签。
This uses git log
to get a list of commits in a branch, and then passes them to git describe
to see if they correspond to a tag.
这篇关于Git能够检索仅存在于特定分支中的标签列表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文