Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show all branches that commit A is on and commit B is not on?

Tags:

git

branch

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.

like image 413
Cellze Avatar asked Apr 17 '12 07:04

Cellze


1 Answers

Have you tried this:

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

It is far from perfect but it might help.

like image 146
Pierre Mage Avatar answered Oct 07 '22 15:10

Pierre Mage