且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当前分支和主节点之间的Git差异,但不包括未合并的主节点提交

更新时间:2022-11-30 18:19:43

git diff `git merge-base master branch`..branch

合并基础分支code>与 master 不同.

Merge base is the point where branch diverged from master.

Git diff为此支持特殊的语法:

git diff master...branch

您不得交换双方,因为那样您将获得另一个分支.您想知道 branch 中发生了什么变化,因为它与 master 不同,而不是相反.

You must not swap the sides because then you would get the other branch. You want to know what changed in branch since it diverged from master, not the other way round.

松散相关:

请注意, .. ... 语法的语义与其他Git工具中的语义不同.它与 man gitrevisions 中指定的含义不同.

Note that .. and ... syntax does not have the same semantics as in other Git tools. It differs from the meaning specified in man gitrevisions.

引用 man git-diff :

  • git diff [--options]< commit>< commit>[-] [< path>…]

这是为了查看两个任意< commit> 之间的更改.

This is to view the changes between two arbitrary <commit>.

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

这与以前的形式同义.如果省略了一侧的< commit> ,则其效果与使用 HEAD 的效果相同.

This is synonymous to the previous form. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.

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

此表单用于查看包含且直到第二个< commit> 的分支上的更改,该更改始于两个< commit> 的共同祖先." git diff A ... B "等同于" git diff $(git-merge-base A B)B ".您可以省略< commit> 中的任何一个,其效果与使用 HEAD 相同.

This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of <commit>, which has the same effect as using HEAD instead.

仅在您正在做一些异国情调的情况下,应注意的是,上述描述中的所有< commit> ,除了使用."的最后两种形式以外.符号,可以是任何< tree> .

Just in case you are doing something exotic, it should be noted that all of the <commit> in the above description, except in the last two forms that use ".." notations, can be any <tree>.

有关拼写< commit> 的方法的更完整列表,请参见指定版本". gitrevisions [7] 中的部分.但是,"diff"表示关于比较两个端点而不是范围,以及范围符号("< commit> ..< commit< commit< commit""和"< code>< commit> ...<commit> ")并不表示指定范围" gitrevisions [7] 中的部分.

For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in gitrevisions[7]. However, "diff" is about comparing two endpoints, not ranges, and the range notations ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as defined in the "SPECIFYING RANGES" section in gitrevisions[7].