gpt4 book ai didi

git - 无法想到 git diff master..lab 和 git diff master...lab 会不同的情况

转载 作者:太空狗 更新时间:2023-10-29 13:28:52 24 4
gpt4 key购买 nike

git diff master..lab 

它将在两个分支的提示之间产生差异。

git diff master...lab # notice triple dot

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

我想不出双点的结果与三点的结果不同的任何情况。

最佳答案

我知道您已经看到了,但这里是文档中的两个片段:

git diff [--options] <commit>..<commit> [--] [<path>...]

This is synonymous to the previous form. (git diff [--options] <commit> <commit> [--] [<path>...])

git diff [--options] <commit>...<commit> [--] [<path>...]

This form is to view the changes on the branch containing and up to the second , starting at a common ancestor of both . git diff A...B is equivalent to git diff $(git-merge-base A B) B.

我知道这可能会让您感到困惑 - ..... git diff 的表示法与修订列表(例如 git log)的表示法不同。

假设我们的历史是这样的:

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

第一个片段告诉我们git diff master..lab相当于git diff master lab ,换句话说 git diff E G .这将告诉我们 E 之间的直接区别和 G - 即我们将看到 F 的组合, G , 以及 D 的反向补丁和 E .

另一方面,git diff master...lab相当于git diff C G - 它显示了从两者的共同祖先(master 和 lab 的 merge 基础,即 C )开始到第二次提交(lab)的更改。我们看到的差异将是 F 的组合和 G .它不包括 DE .

三点符号的用例是当您想要查看您在主题分支(实验室)上完成但尚未 merge 到主分支中的所有工作时。您不关心在 master 上还做了什么 - 您只对您在主题分支上所做的工作感兴趣。

关于git - 无法想到 git diff master..lab 和 git diff master...lab 会不同的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2539040/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com