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?
So when you are on a dev branch and Tag this state. Your tag is on the actual reference. So in this case you can look to gitk or another tool where the tree is shown. There you can see on which reference the Tag is.
Tags and branch are completely unrelated, since tags refer to a specific commit, and branch is a moving reference to the last commit of a history. Branches go, tags stay. So when you tag a commit, git doesn't care which commit or branch is checked out, if you provide him the SHA1 of what you want to tag.
Yes! The difference between a branch name and a tag name is that a branch name is expected to move, and git will move it automatically in that "on a branch" case.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With