How to get only unique commits in git

谁说我不能喝 提交于 2019-12-25 18:51:55

问题


I want to get list of unique commits in all branches, but if somebody is using rebase in branch commits loose parents. How to solve this problem? How to get list of commits that made unique changes?


回答1:


I use

git log --oneline --graph --cherry-pick --left-right

The operative verb you are looking for is --cherry-pick:

--cherry-pick

Omit any commit that introduces the same change as another commit on the "other side" when the set of commits are limited with symmetric difference.

For example, if you have two branches, A and B, a usual way to list all commits on only one side of them is with --left-right, like the example above in the description of that option. It however shows the commits that were cherry-picked from the other branch (for example, "3rd on b" may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.

The addition of left-right makes it easier to see differences between branches:

git log --oneline --graph --cherry-pick --left-right BRANCH1...BRANCH2

< 6abfdcf only on BRANCH1
> 7b2127a only on BRANCH2
> 919ca24 only on BRANCH2

Here, also, cherry-picks or merged commits are 'hidden' from view



来源:https://stackoverflow.com/questions/9184378/how-to-get-only-unique-commits-in-git

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