本文介绍了无法想到一个情况,其中git diff master..lab和git diff master ... lab会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git diff master..lab 

两个分支尖端之间的差异。

  git diff master ... lab#notice triple dot 

它会从两个分支的共同祖先开始差异。



我无法想象在任何情况下,双点的结果与三点的结果不同。 我知道你已经看到了这个,但以下是文档中的两个片段:

我可以看到这会如何混淆你 - .. ... git diff的表示法并不意味着它们与修订列表(例如git log)相同。



假设我们的历史如下所示:

  A  -  B  -  C  -  D  -  E(主)
\
F - G(lab)

第一段代码告诉我们 git diff master..lab 相当于 git diff master lab ,换句话说 git diff EG 。这将告诉我们 E G 之间的直接区别 - 即我们将看到 F G ,以及 D E



另一方面, git diff master ... lab 相当于 git diff CG - 它显示了从两个共同祖先开始的第二个提交(实验室)的变化(master和lab的合并基础,它是 C )。我们看到的差异将是 F G 的组合。它不包括 D E



三点表示法的用例是,当你想查看你在主题分支(实验室)上完成的所有工作时,尚未合并到主工作室中。你不在乎主人还做了什么 - 你只关心你在主题分支上所做的工作。


git diff master..lab 

It will produce the diff between the tips of the two branches.

git diff master...lab # notice triple dot

It will prouduce the diff starting from the common ancestor of the two branches.

I am not able to think of any scenario where the result from double dot would be different from result from triple dot.

解决方案

I know you've seen this, but here's are the two snippets from the docs:

I can see how this might confuse you - the .. and ... notation for git diff don't mean the same thing as they do for revision listing (e.g. for git log).

So suppose our history looks like this:

A - B - C - D - E (master)
         \
          F - G (lab)

The first snippet tells us that git diff master..lab is equivalent to git diff master lab, in other words git diff E G. This will tell us the direct differences between E and G - i.e. we'll see the combination of F, G, and the reverse patches of D and E.

On the other hand, git diff master...lab is equivalent to git diff C G - it shows the changes up to the second commit (lab) starting from the common ancestor of the two (the merge base of master and lab, which is C). The diff we see will be the combination of F and G. It does not include D and E.

The use case for the triple dot notation is when you want to see all the work you've done on your topic branch (lab) that's not merged into master yet. You don't care what else has been done on master - you're only interested in the work you're doing on your topic branch.

这篇关于无法想到一个情况,其中git diff master..lab和git diff master ... lab会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 03:53