Show all branches that commit A is on and commit B

2019-06-17 08:10发布

问题:

I have multiple branches and have discovered a commit A that introduced a bug into the system. This was subsequently fixed by commit B on one of the branches and merged back to master, but at the time it was not cherry-picked to all offending branches.

I was wondering if there is a command that will show all offending branches that have commit A but do not have commit B?

I have been using the following to determine that a commit exists on a branch

$ git branch -r --contains=A

but I want to try and add to this to include something like

$ git branch -r --contains=A ^--contains=B

As a side note I have checked and there are no other commits that contain the same change, i.e. it has not been cherry-picked on to any other branches, but some branches have commit B where they have diverged from master since the merge and some don't where they already existed before commit B was introduced.

Additionally the ability to check for several commits would be useful where the commit that has fixed an issue (commit B in this case) is cherry-picked onto several branches already giving different commit SHA's.

回答1:

Have you tried this:

diff <(git branch -r --contains=A) <(git branch -r --contains=B)

It is far from perfect but it might help.



标签: git branch