I'm trying to find out how I can list all the tags that contains a given commit including those that were cherry-picked.
For example:
- I have a commit
abcd1234
, which has been merged into themaster
branch. - This gives me a merge commit with hash
a1b2c3d4
- I create a tag at this point named release-1.0
At this point, I can use git tag --contains abcd1234
OR git tag --contains a1b2c3d4
. Both of these commands will list the tag release-1.0
Now:
- I created a hot-fix branch from release-1.0 tag
- I have a new merge commit on the master with the hash
xyz789
- I cherry-pick this commit onto the hot-fix branch
- I tag this hot-fix branch as release-1.1 and delete the branch
How can I get a list of all the tags that contains commit xyz789
? In this case, it should show that this commit is available in:
- release-1.1
The problem here is that
release-1.1
does not contain commitxyz789
(which is also not a valid hash ID, but never mind that :-) ). Cherry-picking creates a new, different commit, with a new, different hash ID.Rather than attempting to track which commits are copies of which other commits—this is possible; see the
-x
argument togit cherry-pick
—it's better to apply the hot-fix commit as a branch, whether temporary or not, that gets created right after the commit(s) where the problem first occurs. This commit can then be merged to multiple different branches. See What are the perils of cherry picking in git between two branches A and B if I am never going to merge between them? and follow the links to Raymond Chen's blog posts.