Skip to content

Commit f302c1e

Browse files
committed
revisions(7): clarify that most commands take a single revision range
Sometimes new people are confused by how a revision "range" works, in that it is not a random collection of commits but a set of commits that are all connected to each other, and most Git commands work on a single such "range". Give an example to clarify it. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48bf2fa commit f302c1e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Documentation/revisions.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ any of the given commits.
260260
A commit's reachable set is the commit itself and the commits in
261261
its ancestry chain.
262262

263+
There are several notations to specify a set of connected commits
264+
(called a "revision range"), illustrated below.
265+
263266

264267
Commit Exclusions
265268
~~~~~~~~~~~~~~~~~
@@ -294,6 +297,26 @@ is a shorthand for 'HEAD..origin' and asks "What did the origin do since
294297
I forked from them?" Note that '..' would mean 'HEAD..HEAD' which is an
295298
empty range that is both reachable and unreachable from HEAD.
296299

300+
Commands that are specifically designed to take two distinct ranges
301+
(e.g. "git range-diff R1 R2" to compare two ranges) do exist, but
302+
they are exceptions. Unless otherwise noted, all "git" commands
303+
that operate on a set of commits work on a single revision range.
304+
In other words, writing two "two-dot range notation" next to each
305+
other, e.g.
306+
307+
$ git log A..B C..D
308+
309+
does *not* specify two revision ranges for most commands. Instead
310+
it will name a single connected set of commits, i.e. those that are
311+
reachable from either B or D but are reachable from neither A or C.
312+
In a linear history like this:
313+
314+
---A---B---o---o---C---D
315+
316+
because A and B are reachable from C, the revision range specified
317+
by these two dotted ranges is a single commit D.
318+
319+
297320
Other <rev>{caret} Parent Shorthand Notations
298321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299322
Three other shorthands exist, particularly useful for merge commits,

0 commit comments

Comments
 (0)