如何在git中仅获取唯一的提交 [英] How to get only unique commits in git

查看:119
本文介绍了如何在git中仅获取唯一的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取所有分支中唯一提交的列表,但是如果有人在分支中使用rebase则提交松散的父母.如何解决这个问题呢?如何获取做出独特更改的提交列表?

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?

推荐答案

我使用

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

您要查找的操作动词--cherry-pick :

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

--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.

例如,如果您有两个分支A和B,则通常只使用--left-right列出所有提交的一侧,就像上面该选项说明中的示例一样.但是,它显示了从另一个分支中精选的提交(例如,"3rd on b"可能是从分支A中精选的).使用此选项时,这样的提交对将从输出中排除.

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

这篇关于如何在git中仅获取唯一的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆