Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 2b9232c

Browse files
glandiumgitster
authored andcommitted
Describe two-dot and three-dot notation for diff endpoints.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6257271 commit 2b9232c

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

Documentation/git-diff.txt

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ tree and the index file, or the index file and the working tree.
2222
words, the differences are what you _could_ tell git to
2323
further add to the index but you still haven't. You can
2424
stage these changes by using gitlink:git-add[1].
25-
26-
If exactly two paths are given, and at least one is untracked,
27-
compare the two files / directories. This behavior can be
28-
forced by --no-index.
25+
+
26+
If exactly two paths are given, and at least one is untracked,
27+
compare the two files / directories. This behavior can be
28+
forced by --no-index.
2929

3030
'git-diff' [--options] --cached [<commit>] [--] [<path>...]::
3131

@@ -44,16 +44,33 @@ tree and the index file, or the index file and the working tree.
4444

4545
'git-diff' [--options] <commit> <commit> [--] [<path>...]::
4646

47-
This form is to view the changes between two <commit>,
48-
for example, tips of two branches.
47+
This is to view the changes between two arbitrary
48+
<commit>.
49+
50+
'git-diff' [--options] <commit>..<commit> [--] [<path>...]::
51+
52+
This is synonymous to the previous form. If <commit> on
53+
one side is omitted, it will have the same effect as
54+
using HEAD instead.
55+
56+
'git-diff' [--options] <commit>...<commit> [--] [<path>...]::
57+
58+
This form is to view the changes on the branch containing
59+
and up to the second <commit>, starting at a common ancestor
60+
of both <commit>. "git-diff A...B" is equivalent to
61+
"git-diff $(git-merge-base A B) B". You can omit any one
62+
of <commit>, which has the same effect as using HEAD instead.
4963

5064
Just in case if you are doing something exotic, it should be
5165
noted that all of the <commit> in the above description can be
5266
any <tree-ish>.
5367

5468
For a more complete list of ways to spell <commit>, see
5569
"SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
56-
70+
However, "diff" is about comparing two _endpoints_, not ranges,
71+
and the range notations ("<commit>..<commit>" and
72+
"<commit>...<commit>") do not mean a range as defined in the
73+
"SPECIFYING RANGES" section in gitlink:git-rev-parse[1].
5774

5875
OPTIONS
5976
-------
@@ -97,6 +114,18 @@ the tip of the current branch, but limit the comparison to the
97114
file "test".
98115
<3> Compare the version before the last commit and the last commit.
99116

117+
Comparing branches::
118+
+
119+
------------
120+
$ git diff topic master <1>
121+
$ git diff topic..master <2>
122+
$ git diff topic...master <3>
123+
------------
124+
+
125+
<1> Changes between the tips of the topic and the master branches.
126+
<2> Same as above.
127+
<3> Changes that occured on the master branch since when the topic
128+
branch was started off it.
100129

101130
Limiting the diff output::
102131
+

0 commit comments

Comments
 (0)