问题
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