有人可以解释git range-diff的用法吗? [英] Can somebody explain the usage of git range-diff?
问题描述
Git版本2.19引入了git range-diff
,它应该用于比较两个提交范围.我一直在阅读文档,但是我无法了解此新功能的目的.
Git version 2.19 introduces git range-diff
which is supposed to be used in order to compare two commit ranges. I have been reading the documentation, but I cannot get what is the purpose of this new features.
我检查了官方 Git文档,但在理解其语法时遇到了麻烦(省略标志):
I checked the official Git documentation, and I have trouble understanding its syntax (omitting flags):
git range-diff ( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> )
什么是rev1
和rev2
?
每个人都可以解释一下什么时候有用吗?
Could somebody explain when they are useful I mean each case?
推荐答案
我尚未实际使用它们,但它们是对旧的git cherry*
流程的改进,用于分析/比较某些上游或下游变更集与您现在拥有的.为了使范围集有用,我们需要一些这里是我的提交".和这里是他们的",表示方式尽可能简单.
I have not actually used them yet, but they are meant as an improvement over the old git cherry*
flow for analysing / comparing some upstream or downstream change-set vs what you have now. To make the range-sets useful we want some set of "here are my commits" and "here are theirs", expressed as simply as possible.
range1 range2 集将写为例如:
git range-diff theirs~5..theirs ours~4..ours
如果有的话,例如:
T1--T2--T3--T4--T5 <-- theirs
/
...--o--* <-- base
\
O1--O2--O3--O4 <-- ours
其中,O
提交是我们的".并且T
提交是他们的".
where the O
commits are "ours" and the T
commits are "theirs".
鉴于此配置完全相同,我们还可以编写:
Given this exact same configuration, however, we could also write:
git range-diff theirs...ours # or ours...theirs
(请注意三个点). (例如,这是git rev-list --cherry-mark --left-right
所使用的语法.)
(note the three dots). (This is the syntax used with git rev-list --cherry-mark --left-right
, for instance.)
或者,再次鉴于这种情况,我们可以这样写:
Or, again given this same situation, we could write:
git range-diff base theirs ours # or base ours theirs
这里base
是他们和我们俩的出发点,避免了倒数5.
Here base
is the stop point for both theirs and ours, and avoids having to count back 5.
如果情况更加复杂-如图所示:
If the situation is more complicated—as in the graph:
X1--T1--T2--T3 <-- theirs
/
...--o--* <-- base
\
Y1--Y2--O1--O2--O3--O4 <-- ours
三点语法和base ours theirs
语法都不起作用,因此最好使用两组范围(theirs~3..theirs ours~4..ours
).
neither the three-dot nor the base ours theirs
kind of syntax quite works, so the two sets of ranges (theirs~3..theirs ours~4..ours
) would be best.
这篇关于有人可以解释git range-diff的用法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!