three dots in git
What are the differences between double-dot “..” and triple-dot “…” in Git commit ranges?
Using Commit Ranges with Git Log
When you're using commit ranges like ..
and ...
with git log
, the difference between them is that, for branches A and B,
git log A..B
will show you all of the commits that B has that A doesn't have, while
git log A...B
will show you both the commits that A has and that B doesn't have, and the commits that B has that A doesn't have, or in other words, it will filter out all of the commits that both A and B share, thus only showing the commits that they don't both share.
Visualization with Venn Diagrams & Commit Trees
Here is a visual representation of git log A..B
. The commits that branch B contains that don't exist in A is what is returned by the commit range, and is highlighted in red in the Venn diagram, and circled in blue in the commit tree:
These are the diagrams for git log A...B
. Notice that the commits that are shared by both branches are not returned by the command:
Making the Triple-Dot Commit Range ...
More Useful
You can make the triple-dot commit range ...
more useful in a log command by using the --left-right
option to show which commits belong to which branch:
$ git log --oneline --decorate --left-right --graph master...origin/master
< 1794bee (HEAD, master) Derp some more
> 6e6ce69 (origin/master, origin/HEAD) Add hello.txt
In the above output, you'll see the commits that belong to master
are prefixed with <
, while commits that belong to origin/master
are prefixed with >
.
Using Commit Ranges with Git Diff
Someday I might add my own explanation for how the commit ranges work with git diff
, but for now, you might want to check out What are the differences between double-dot ".." and triple-dot "..." in Git diff commit ranges?.
See Also
https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Commit-Ranges
Double Dot
The most common range specification is the double-dot syntax.
This basically asks Git to resolve a range of commits that are reachable from one commit but aren’t reachable from another.
For example, say you have a commit history that looks like Example history for range selection..

Say you want to see what is in your experiment
branch that hasn’t yet been merged into your master
branch.
You can ask Git to show you a log of just those commits with master..experiment
— that means “all commits reachable from experiment that aren’t reachable from master.”
For the sake目的 of brevity简洁 and clarity清楚 in these examples, the letters of the commit objects from the diagram are used in place of the actual log output in the order that they would display:
$ git log master..experiment
D
C
If, on the other hand, you want to see the opposite — all commits in master
that aren’t in experiment
— you can reverse the branch names. experiment..master
shows you everything in master
not reachable from experiment
:
$ git log experiment..master
F
E
This is useful if you want to keep the experiment
branch up to date and preview what you’re about to merge. Another frequent use of this syntax is to see what you’re about to push to a remote:
$ git log origin/master..HEAD
This command shows you any commits in your current branch that aren’t in the master
branch on your origin
remote. If you run a git push
and your current branch is tracking origin/master
, the commits listed by git log origin/master..HEAD
are the commits that will be transferred to the server. You can also leave off one side of the syntax to have Git assume HEAD
. For example, you can get the same results as in the previous example by typing git log origin/master..
— Git substitutes HEAD
if one side is missing.
Multiple Points
The double-dot syntax is useful as a shorthand, but perhaps you want to specify more than two branches to indicate your revision, such as seeing what commits are in any of several branches that aren’t in the branch you’re currently on. Git allows you to do this by using either the ^
character or --not
before any reference from which you don’t want to see reachable commits. Thus, the following three commands are equivalent:
$ git log refA..refB
$ git log ^refA refB
$ git log refB --not refA
This is nice because with this syntax you can specify more than two references in your query, which you cannot do with the double-dot syntax. For instance, if you want to see all commits that are reachable from refA
or refB
but not from refC
, you can use either of:
$ git log refA refB ^refC
$ git log refA refB --not refC
This makes for a very powerful revision query system that should help you figure out what is in your branches.
Triple Dot
The last major range-selection syntax is the triple-dot syntax, which specifies all the commits that are reachable by either of two references but not by both of them. Look back at the example commit history in Example history for range selection.. If you want to see what is in master
or experiment
but not any common references, you can run:
$ git log master...experiment
F
E
D
C
Again, this gives you normal log
output but shows you only the commit information for those four commits, appearing in the traditional commit date ordering.
A common switch to use with the log
command in this case is --left-right
, which shows you which side of the range each commit is in. This helps make the output more useful:
$ git log --left-right master...experiment
< F
< E
> D
> C
With these tools, you can much more easily let Git know what commit or commits you want to inspect.
https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-Theem82308203emthree-dotSymmetricDifferenceNotation
SPECIFYING RANGES
History traversing commands such as git log
operate on a set of commits, not just a single commit.
For these commands, specifying a single revision, using the notation described in the previous section, means the set of commits reachable
from the given commit.
A commit’s reachable set is the commit itself and the commits in its ancestry chain.
Commit Exclusions
- ^<rev> (caret) Notation
-
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 (i.e. r1 and its ancestors).
Dotted Range Notations
- The .. (two-dot) Range Notation
-
The ^r1 r2 set operation appears so often that there is a shorthand for it. When you have two commits r1and 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.
- The … (three-dot) Symmetric Difference Notation
-
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 (left side) or r2(right side) but not from both.
In these two shorthand notations, you can omit one end and let it default to HEAD. For example, origin..is a shorthand for origin..HEAD and asks "What did I do since I forked from the origin branch?" Similarly, ..origin is a shorthand for HEAD..origin and asks "What did the origin do since I forked from them?" Note that .. would mean HEAD..HEAD which is an empty range that is both reachable and unreachable from HEAD.
https://public-inbox.org/git/nycvar.QRO.7.76.6.1905281154390.44@tvgsbejvaqbjf.bet/
From
https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-Theem82308203emthree-dotSymmetricDifferenceNotation: The ... (three-dot) Symmetric Difference Notation 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 (left side) or r2 (right side) but not from both. Most importantly, the next paragraph states: In these two shorthand notations, you can omit one end and let it
default to HEAD. What it does *not* say is that you can leave out both ends, in which case
it becomes the non-sensical short form of `HEAD...HEAD`, as Hannes pointed
out. Ciao,
Johannes
three dots in git的更多相关文章
- git CVE-2014-9390 验证以及源码对比
一 验证部分 首先在ubuntu下面建立如下工程 mkdir repo cd repo git init mkdir -p .GiT/hooks cp post-checkout .GiT/hooks ...
- vim + oh-my-zsh + git搭建开发环境
vim + oh-my-zsh + git配置开发环境 vim配置 安装vundle 使用vundle作为插件管理器,使用前先安装vundle mkdir -p ~/.vim/bundle git c ...
- Git 子模块 - submodule
有种情况我们经常会遇到:某个工作中的项目需要包含并使用另一个项目. 也许是第三方库,或者你 独立开发的,用于多个父项目的库. 现在问题来了:你想要把它们当做两个独立的项目,同时又想在 一个项目中使用另 ...
- Git 在团队中的最佳实践--如何正确使用Git Flow
我们已经从SVN 切换到Git很多年了,现在几乎所有的项目都在使用Github管理, 本篇文章讲一下为什么使用Git, 以及如何在团队中正确使用. Git的优点 Git的优点很多,但是这里只列出我认为 ...
- Git与Repo入门
版本控制 版本控制是什么已不用在说了,就是记录我们对文件.目录或工程等的修改历史,方便查看更改历史,备份以便恢复以前的版本,多人协作... 一.原始版本控制 最原始的版本控制是纯手工的版本控制:修改文 ...
- Git Bash的一些命令和配置
查看git版本号: git --version 如果是第一次使用Git,你需要设置署名和邮箱: $ git config --global user.name "用户名" $ gi ...
- 在Ubuntu 16.10 安装 git 并上传代码至 git.oschina.net
1. 注册一个账号和创建项目 先在git.oschina.net上注册一个账号和新建一个project ,如project name 是"myTest". 2.安装git sudo ...
- 史上最详细git教程
题外话 虽然这个标题很惊悚,不过还是把你骗进来了,哈哈-各位看官不要着急,耐心往下看 Git是什么 Git是目前世界上最先进的分布式版本控制系统. SVN与Git的最主要的区别 SVN是集中式版本控制 ...
- [版本控制之道] Git 常用的命令总结(欢迎收藏备用)
坚持每天学习,坚持每天复习,技术永远学不完,自己永远要前进 总结日常开发生产中常用的Git版本控制命令 ------------------------------main-------------- ...
随机推荐
- poj2236Wireless Network
Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have ...
- 舔狗【2019河北省大学生程序设计竞赛 J题】
题目描述 > “舔狗舔狗,> 舔到最后,> 一无所有.” 有 n 只舔狗,每只舔狗的心中都有自己朝思暮想的一位. 每个人虽然受到了一万次拒绝,还毅然第一万零一次鼓起勇气. 作为一个不 ...
- Angular 输入中的禁止特定输入值--Validator 与 Directive 实现
1 前言 最近在项目中涉及表单的情况下,需要对用户输入进行过滤,比如填写用户名的时候不可以使用空格或者特殊符号,这里有几个解决方法: 使用 Angular 的正则同步验证器 使用 RxJS对输入的值进 ...
- final、以及public、protected、(default)、private权限修饰符总结
package cn.learn.Final; /* 当final用来修饰类 1.该类不能有任何子类,成员方法均无法覆盖重写,但可以重写父类的方法 当final用来修饰方法 1.该方法不能被覆盖重写 ...
- [功能集锦] 002 - mysql查询数据库字典+导出+样式一键整合至excel
写在前面: 因为工作时候经常遇到半路接手项目的情况,由于年代久远,数据库字典这块经常缺失.故写此篇,以便复用,也希望对大家有点帮助. 随笔内容不高级,如有不妥,不吝指正. 20190730-加了一些简 ...
- 转义BABEL的POLYFILL和RUNTIME的区别
babel-polyfill 使用场景 Babel 默认只转换新的 JavaScript 语法,而不转换新的 API.例如,Iterator.Generator.Set.Maps.Proxy.Refl ...
- POJ1742 coins 动态规划之多重部分和问题
原题链接:http://poj.org/problem?id=1742 题目大意:tony现在有n种硬币,第i种硬币的面值为A[i],数量为C[i].现在tony要使用这些硬币去买一块价格不超过m的表 ...
- thinkphp开发微信小程序后台流程
thinkphp开发微信小程序后台流程,简单分享一下微信开发流程 1,注册微信小程序账号 2,注册好后,登陆微信小程序,下载微信小程序开发工具 3,用thinkphp开发企业后台,前台数据用json返 ...
- jquery遍历获取带checkbox表格的选中值以及遍历json数组
今天整理了一下jquery遍历的两个用法,分享给大家. 1.$().each 主要用来遍历DOM元素,获取DOM的值或样式等. 2.$.each() 主要用来遍历后台ajax返回的json数组,循环将 ...
- TMS320C6455BCTZA 原厂订购 原装正品
作为一家科研公司,保证芯片的原厂品质和正规采购渠道是科学严谨的研发工作中重要的一环,更是保证研发产品可靠.稳定的基础.而研发中所遇到的各种不可预测的情况更是每个工程师向技术的山峰攀登中时会遇到的各种难 ...