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

Viacheslav Kondratiuk picture Viacheslav Kondratiuk · Apr 4, 2013 · Viewed 57.5k times · Source

I'm currently busy with a 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 is.

How to find out on which branch a tag is?

Answer

VonC picture VonC · Apr 4, 2013

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>