tags:

views:

434

answers:

1

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's the difference?

+7  A: 

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

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 , starting at a common ancestor of both . "git
diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can
omit any one of , which has the same effect as using HEAD
instead.

Which is a big 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.

Pieter
This seems like a dark corner -- I'm glad I'll have this to jog my memory. Thanks!
Pat Notz