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

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

问题描述

以下命令之间有什么区别?:

  git diff foo master#a 
git diff foo..master#b
git diff foo ... master#c

从它们的参数中解析提交列表。)

.. ... 可以显示为 git log





因此, git rev-list foo..bar 显示了分支 foo 以外的分支 bar 上的所有内容。另一方面, git rev-list foo ... bar 显示了 foo 中的所有提交, bar ,但不能 。第三个图表显示了如果你列出了两个分支,你将得到它们中的一个或两个的提交。



好吧,我发现所有的一点)无论如何,我认为提交图表有助于:)

1我只是说典型,因为解决合并冲突时,例如 git diff 会向你显示三向合并。


What are the differences between the following commands?:

git diff foo master   # a 
git diff foo..master  # b
git diff foo...master # c

The diff manual talks about it:

Comparing branches

$ git diff topic master    <1>
$ git diff topic..master   <2>
$ git diff topic...master  <3>

  1. Changes between the tips of the topic and the master branches.
  2. Same as above.
  3. Changes that occurred on the master branch since when the topic branch was started off it.

but isn't totally clear to me.

解决方案

Since I'd already created these images, I thought it might be worth using them in another answer, although the description of the difference between .. (dot-dot) and ... (dot-dot-dot) is essentially the same as in manojlds's answer.

The command git diff typically¹ only shows you the difference between the states of the tree between exactly two points in the commit graph. The .. and ... notations in git diff have the following meanings:

In other words, git diff foo..bar is exactly the same as git diff foo bar; both will show you the difference between the tips of the two branches foo and bar. On the other hand, git diff foo...bar will show you the difference between the "merge base" of the two branches and the tip of bar. The "merge base" is usually the last commit in common between those two branches, so this command will show you the changes that your work on bar has introduced, while ignoring everything that has been done on foo in the mean time.

That's all you need to know about the .. and ... notations in git diff. However...


... a common source of confusion here is that .. and ... mean subtly different things when used in a command such as git log that expects a set of commits as one or more arguments. (These commands all end up using git rev-list to parse a list of commits from their arguments.)

The meaning of .. and ... for git log can be shown graphically as below:

So, git rev-list foo..bar shows you everything on branch bar that isn't also on branch foo. On the other hand, git rev-list foo...bar shows you all the commits that are in either foo or bar, but not both. The third diagram just shows that if you list the two branches, you get the commits that are in either one or both of them.

Well, I find that all a bit confusing, anyway, and I think the commit graph diagrams help :)

¹ I only say "typically" since when resolving merge conflicts, for example, git diff will show you a three-way merge.

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

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