Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying a tag belongs to which branch in git

I first did repo sync to a manifest for a branch name myBranch. I then get the tags from

git tag -l

Now I want to know using git that each tag obtained as a result of git tag -l was actually created on which branch. Please note : I do not want myBranch as the output but the remote branch name on which the tag was created.

like image 771
iDev Avatar asked Dec 08 '22 23:12

iDev


1 Answers

Keeping aside the fact that branches can be renamed or deleted at any time (without losing any commits, which can still be referenced in the path of another branch), the best you can do is:

  • get the branches that contains the commit referenced by the tag

See "Show the original branch for a commit", combined with "Git - how to tell which commit a tag points to".
(Ie, a combination of git rev-parse <tag>~0 with git branch --contains <sha1>)

This has nothing to do with the branch on which the tag was created, but rather the branch(es) which currently reference said tag.

like image 133
VonC Avatar answered Dec 22 '22 16:12

VonC