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

ぐ巨炮叔叔 提交于 2020-01-03 08:41: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.



来源:https://stackoverflow.com/questions/10187302/show-all-branches-that-commit-a-is-on-and-commit-b-is-not-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!