What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges?

Pat Notz picture Pat Notz · Jan 20, 2009 · Viewed 67.6k times · Source

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?

Answer

user456814 picture user456814 · Jun 12, 2014

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:

 "git log A..B" diagramTree 1

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:

 "git log A...B" diagramTree 2

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