双点“..”之间的区别是什么?和三点“...”在Git提交范围? [英] What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges?

查看:484
本文介绍了双点“..”之间的区别是什么?和三点“...”在Git提交范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些Git命令使用提交范围,一种有效的语法是用两个点 .. 分隔两个提交名称,另一个语法使用三个点 ...



两者有什么不同?

解决方案

这取决于您是使用 log 命令还是使用 diff 命令。在 log 情况下,它位于 man git-rev-parse 文档中:


要排除提交可达的提交,使用前缀^符号。例如。 ^ r1 r2表示提交从r2到达但不包括可从r1到达的那些。



这个设置操作经常出现
,因此有一个简写。当
时,你有两个提交r1和r2(根据上面
SPECIFYING REVISIONS中解释的语法命名),你可以
请求从r2到达
的提交,是
可以从r1通过^ r1 r2到达并且
可以写成r1..r2。

类似的记法 r1 ... r2是
,称为r1和
r2的对称差,并且定义为r1 r2 - 不是
$(git merge-base --all r1 r2)。它是
提交的集合,可以从r1或r2
中的任何一个到达
,但不能从两者中获得。


这基本上意味着你会得到两个分支中的任何一个的所有提交,但不是都提交。



diff 大小写,它位于 man git-diff 文档中:


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

此表单用于查看分支上的更改,其中包含高达
的第二个< commit>
< commit>的祖先。 git diff A ... B相当于git diff
$(git-merge-base A B)B。您可以省略< commit>中的任何一个,其中
与使用HEAD具有相同的效果。


这有点模糊。基本上,它意味着它只显示与另一个分支相比在该分支中的差异:它会查找最后一次提交给你的第一个committish,然后将第二个committish与第二个committish区分开来。与此分支相比,这是一种简单的方法,可以查看该分支所做的更改,而无需仅注意此分支中的更改。



比较简单:在 git-diff 的情况下,它与 git diff AB ,只是将A与B区分开来。在 log 的情况下,它显示所有在B中但不在A中的提交。


Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots .., and another syntax uses three dots ....

What are the differences between the two?

解决方案

It depends on whether you're using a log command or a diff command. In the log case, it's in the man git-rev-parse documentation:

To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2 but exclude the ones reachable from r1.

This set operation appears so often that there is a shorthand for it. When you have two commits r1 and r2 (named according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2 excluding those that are reachable from r1 by "^r1 r2" and it can be written as "r1..r2".

A similar notation "r1...r2" is called symmetric difference of r1 and r2 and is defined as "r1 r2 --not $(git merge-base --all r1 r2)". It is the set of commits that are reachable from either one of r1 or r2 but not from both.

Which basically means that you'll get all commits that are in either of the two branches, but not in both.

In the diff case, it's in the man git-diff documentation:

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

      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.

Which is a bit fuzzy. Basically it means it shows only the differences in that branch compared to another branch: it looks for the last common commit with the first committish you gave it, and then diffs the second committish to that. It's an easy way to see what changes are made in that branch, compared to this branch, without taking notice of changes in this branch only.

The .. is somewhat simpler: In the git-diff case, it's the same as a git diff A B and just diffs A against B. In the log case, it shows all commits that are in B but not in A.

这篇关于双点“..”之间的区别是什么?和三点“...”在Git提交范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆