我怎样才能找到Git仓库中拥有多个父项的所有提交? [英] How can I find all the commits that have more than one parent in a Git repository?
问题描述
对于repo中的每个合并,我需要找到基础(最近的共同祖先),这两个贡献者以及由此产生的合并提交。
我已经知道如何获得最近的共同祖先( git merge-base rev1 rev2
)和贡献者( git log --pretty =%P -n 1< commit>
),但我遇到问题,提交由合并操作产生的结果。
如何在Git存储库中找到所有包含多个父代的提交?
<解决方案
这应该是足够的(对于本地提交)
git rev-list --merges
The git rev-list
手册页提及:
- 合并
<强>点rint仅合并提交。这与
- min-parents = 2
。
完全相同。这意味着rev-list有一些有趣的过滤器:
- min-parents =< number>
--max-parents =< number>
只显示至少有(或至多)很多的提交提交。
特别是:
- 相同
- max-parents = 1
与- no-merges
,
- min-parents = 2
与- 合并
相同。
- max-parents = 0
会给出所有根提交和$ / $> b- 。
- min-parents = 3
所有章鱼合并
I am working on a research to study merges in open source projects.
For each merge in the repo I need to find the base (nearest common ancestor), the two contributors, and the resulting merged commit.
I already have an idea of how to get the nearest common ancestor (git merge-base rev1 rev2
) and the contributors (git log --pretty=%P -n 1 <commit>
), but I am having problem identifying the commits that resulted from a merge operation.
How can I find all the commits that have more than one parent in a Git repository?
This should be enough (for local commit)
git rev-list --merges
The git rev-list
man page mentions:
--merges
Print only merge commits. This is exactly the same as
--min-parents=2
.
That means rev-list has some interesting filters:
--min-parents=<number>
--max-parents=<number>
Show only commits which have at least (or at most) that many commits.
In particular:
--max-parents=1
is the same as--no-merges
,--min-parents=2
is the same as--merges
.--max-parents=0
gives all root commits and--min-parents=3
all octopus merges.
这篇关于我怎样才能找到Git仓库中拥有多个父项的所有提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!