Viacheslav Kondratiuk Viacheslav Kondratiuk - 23 days ago 7
Git Question

Git: How to find out on which branch tag is?

I'm currently busy with project with a lot of branches and I have a tag for last changes which where done on one of the branches. But it's not clear for me on which branch this tag.

How to find out on which branch tag is?

Answer

Even shorter:

git branch --contains tags/<tag>

(it works for any tree-ish reference)


If you can find which commit a tag refers to:

 git rev-parse --verify tags/<tag>^{commit}
 # or, shorter:
 git rev-parse tags/<tag>~0

Then you can find which branch contain that commit.

git branch --contains <commit>

As commented below by user3356885, for the fetched branches (branches in remotes namespace)

git branch -a --contains tags/<tag>
git branch -a --contains <commit>