Listing the tags in git from a specific branch

最后都变了- 提交于 2020-01-13 20:48:29

问题


I have used repo sync to a repository (from head) and have passed a branch named (mybranch). I got a list of tags in git by using:

git tag -l

Then with the help of a regular expression I obtained the tags which match a specific pattern.

Is it possible to get the branch name of those shortlisted tags and then select only the tags only from a particular branch?

I saw git branch -r command but can it be used along with the tag name as well?


回答1:


Assuming you want the branches which refer to a commit referred by a tag:

git branch --contains <tagname>

Just repeat the command for each tag you are looking the branch(es) of:

git tag -l 'example*' |xargs -n1 git branch --contains

Be aware, that tags can refer to any object, not only commits, but the 'branch' command expects commits only.



来源:https://stackoverflow.com/questions/11316306/listing-the-tags-in-git-from-a-specific-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!