1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>gitrevisions(
7)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 gitrevisions(
7) Manual Page
409 <div class=
"sectionbody">
411 specifying revisions and ranges for git
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p>gitrevisions
</p></div>
419 <h2 id=
"_description">DESCRIPTION
</h2>
420 <div class=
"sectionbody">
421 <div class=
"paragraph"><p>Many Git commands take revision parameters as arguments. Depending on
422 the command, they denote a specific commit or, for commands which
423 walk the revision graph (such as
<a href=
"git-log.html">git-log(
1)
</a>), all commits which can
424 be reached from that commit. In the latter case one can also specify a
425 range of revisions explicitly.
</p></div>
426 <div class=
"paragraph"><p>In addition, some Git commands (such as
<a href=
"git-show.html">git-show(
1)
</a>) also take
427 revision parameters which denote other objects than commits, e.g. blobs
428 (
"files") or trees (
"directories of files").
</p></div>
430 <h2 id=
"_specifying_revisions">SPECIFYING REVISIONS
</h2>
431 <div class=
"sectionbody">
432 <div class=
"paragraph"><p>A revision parameter
<em><rev
></em> typically, but not necessarily, names a
433 commit object. It uses what is called an
<em>extended SHA1
</em>
434 syntax. Here are various ways to spell object names. The
435 ones listed near the end of this list name trees and
436 blobs contained in a commit.
</p></div>
437 <div class=
"dlist"><dl>
439 <em><sha1
></em>, e.g.
<em>dae86e1950b1277e545cee180551750029cfe735
</em>,
<em>dae86e
</em>
443 The full SHA1 object name (
40-byte hexadecimal string), or
444 a leading substring that is unique within the repository.
445 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
446 name the same commit object if there is no other object in
447 your repository whose object name starts with dae86e.
451 <em><describeOutput
></em>, e.g.
<em>v1.7
.4.2-
679-g3bee7fb
</em>
455 Output from
<tt>git describe
</tt>; i.e. a closest tag, optionally
456 followed by a dash and a number of commits, followed by a dash, a
457 <em>g
</em>, and an abbreviated object name.
461 <em><refname
></em>, e.g.
<em>master
</em>,
<em>heads/master
</em>,
<em>refs/heads/master
</em>
465 A symbolic ref name. E.g.
<em>master
</em> typically means the commit
466 object referenced by
<em>refs/heads/master
</em>. If you
467 happen to have both
<em>heads/master
</em> and
<em>tags/master
</em>, you can
468 explicitly say
<em>heads/master
</em> to tell git which one you mean.
469 When ambiguous, a
<em><name
></em> is disambiguated by taking the
470 first match in the following rules:
472 <div class=
"olist arabic"><ol class=
"arabic">
475 If
<em>$GIT_DIR/
<name
></em> exists, that is what you mean (this is usually
476 useful only for
<em>HEAD
</em>,
<em>FETCH_HEAD
</em>,
<em>ORIG_HEAD
</em>,
<em>MERGE_HEAD
</em>
477 and
<em>CHERRY_PICK_HEAD
</em>);
482 otherwise,
<em>refs/
<name
></em> if it exists;
487 otherwise,
<em>refs/tags/
<refname
></em> if it exists;
492 otherwise,
<em>refs/heads/
<name
></em> if it exists;
497 otherwise,
<em>refs/remotes/
<name
></em> if it exists;
502 otherwise,
<em>refs/remotes/
<name
>/HEAD
</em> if it exists.
504 <div class=
"paragraph"><p><em>HEAD
</em> names the commit on which you based the changes in the working tree.
505 <em>FETCH_HEAD
</em> records the branch which you fetched from a remote repository
506 with your last
<tt>git fetch
</tt> invocation.
507 <em>ORIG_HEAD
</em> is created by commands that move your
<em>HEAD
</em> in a drastic
508 way, to record the position of the
<em>HEAD
</em> before their operation, so that
509 you can easily change the tip of the branch back to the state before you ran
511 <em>MERGE_HEAD
</em> records the commit(s) which you are merging into your branch
512 when you run
<tt>git merge
</tt>.
513 <em>CHERRY_PICK_HEAD
</em> records the commit which you are cherry-picking
514 when you run
<tt>git cherry-pick
</tt>.
</p></div>
515 <div class=
"paragraph"><p>Note that any of the
<em>refs/*
</em> cases above may come either from
516 the
<em>$GIT_DIR/refs
</em> directory or from the
<em>$GIT_DIR/packed-refs
</em> file.
</p></div>
521 <em><refname
>@{
<date
>}
</em>, e.g.
<em>master@{yesterday}
</em>,
<em>HEAD@{
5 minutes ago}
</em>
525 A ref followed by the suffix
<em>@
</em> with a date specification
527 pair (e.g.
<em>{yesterday}
</em>,
<em>{
1 month
2 weeks
3 days
1 hour
1
528 second ago}
</em> or
<em>{
1979-
02-
26 18:
30:
00}
</em>) specifies the value
529 of the ref at a prior point in time. This suffix may only be
530 used immediately following a ref name and the ref must have an
531 existing log (
<em>$GIT_DIR/logs/
<ref
></em>). Note that this looks up the state
532 of your
<strong>local
</strong> ref at a given time; e.g., what was in your local
533 <em>master
</em> branch last week. If you want to look at commits made during
534 certain times, see
<em>--since
</em> and
<em>--until
</em>.
538 <em><refname
>@{
<n
>}
</em>, e.g.
<em>master@{
1}
</em>
542 A ref followed by the suffix
<em>@
</em> with an ordinal specification
543 enclosed in a brace pair (e.g.
<em>{
1}
</em>,
<em>{
15}
</em>) specifies
544 the n-th prior value of that ref. For example
<em>master@{
1}
</em>
545 is the immediate prior value of
<em>master
</em> while
<em>master@{
5}
</em>
546 is the
5th prior value of
<em>master
</em>. This suffix may only be used
547 immediately following a ref name and the ref must have an existing
548 log (
<em>$GIT_DIR/logs/
<refname
></em>).
552 <em>@{
<n
>}
</em>, e.g.
<em>@{
1}
</em>
556 You can use the
<em>@
</em> construct with an empty ref part to get at a
557 reflog entry of the current branch. For example, if you are on
558 branch
<em>blabla
</em> then
<em>@{
1}
</em> means the same as
<em>blabla@{
1}
</em>.
562 <em>@{-
<n
>}
</em>, e.g.
<em>@{-
1}
</em>
566 The construct
<em>@{-
<n
>}
</em> means the
<n
>th branch checked out
567 before the current one.
571 <em><refname
>@{upstream}
</em>, e.g.
<em>master@{upstream}
</em>,
<em>@{u}
</em>
575 The suffix
<em>@{upstream}
</em> to a ref (short form
<em><refname
>@{u}
</em>) refers to
576 the branch the ref is set to build on top of. A missing ref defaults
577 to the current branch.
581 <em><rev
>^</em>, e.g.
<em>HEAD
^, v1.5
.1^0</em>
585 A suffix
<em>^</em> to a revision parameter means the first parent of
586 that commit object.
<em>^<n
></em> means the
<n
>th parent (i.e.
587 <em><rev
>^</em>
588 is equivalent to
<em><rev
>^1</em>). As a special rule,
589 <em><rev
>^0</em> means the commit itself and is used when
<em><rev
></em> is the
590 object name of a tag object that refers to a commit object.
594 <em><rev
>~<n
></em>, e.g.
<em>master
~3</em>
598 A suffix
<em>~<n
></em> to a revision parameter means the commit
599 object that is the
<n
>th generation grand-parent of the named
600 commit object, following only the first parents. I.e.
<em><rev
>~3</em> is
601 equivalent to
<em><rev
>^^^</em> which is equivalent to
602 <em><rev
>^1^1^1</em>. See below for an illustration of
603 the usage of this form.
607 <em><rev
>^{
<type
>}
</em>, e.g.
<em>v0.99
.8^{commit}
</em>
611 A suffix
<em>^</em> followed by an object type name enclosed in
612 brace pair means the object
613 could be a tag, and dereference the tag recursively until an
614 object of that type is found or the object cannot be
615 dereferenced anymore (in which case, barf).
<em><rev
>^0</em>
616 is a short-hand for
<em><rev
>^{commit}
</em>.
620 <em><rev
>^{}
</em>, e.g.
<em>v0.99
.8^{}
</em>
624 A suffix
<em>^</em> followed by an empty brace pair
625 means the object could be a tag,
626 and dereference the tag recursively until a non-tag object is
631 <em><rev
>^{/
<text
>}
</em>, e.g.
<em>HEAD^{/fix nasty bug}
</em>
635 A suffix
<em>^</em> to a revision parameter, followed by a brace
636 pair that contains a text led by a slash,
637 is the same as the
<em>:/fix nasty bug
</em> syntax below except that
638 it returns the youngest matching commit which is reachable from
639 the
<em><rev
></em> before
<em>^</em>.
643 <em>:/
<text
></em>, e.g.
<em>:/fix nasty bug
</em>
647 A colon, followed by a slash, followed by a text, names
648 a commit whose commit message matches the specified regular expression.
649 This name returns the youngest matching commit which is
650 reachable from any ref. If the commit message starts with a
651 <em>!
</em> you have to repeat that; the special sequence
<em>:/!
</em>,
652 followed by something else than
<em>!
</em>, is reserved for now.
653 The regular expression can match any part of the commit message. To
654 match messages starting with a string, one can use e.g.
<em>:/^foo
</em>.
658 <em><rev
>:
<path
></em>, e.g.
<em>HEAD:README
</em>,
<em>:README
</em>,
<em>master:./README
</em>
662 A suffix
<em>:
</em> followed by a path names the blob or tree
663 at the given path in the tree-ish object named by the part
665 <em>:path
</em> (with an empty part before the colon)
666 is a special case of the syntax described next: content
667 recorded in the index at the given path.
668 A path starting with
<em>./
</em> or
<em>../
</em> is relative to the current working directory.
669 The given path will be converted to be relative to the working tree
’s root directory.
670 This is most useful to address a blob or tree from a commit or tree that has
671 the same tree structure as the working tree.
675 <em>:
<n
>:
<path
></em>, e.g.
<em>:
0:README
</em>,
<em>:README
</em>
679 A colon, optionally followed by a stage number (
0 to
3) and a
680 colon, followed by a path, names a blob object in the
681 index at the given path. A missing stage number (and the colon
682 that follows it) names a stage
0 entry. During a merge, stage
683 1 is the common ancestor, stage
2 is the target branch
’s version
684 (typically the current branch), and stage
3 is the version from
685 the branch which is being merged.
689 <div class=
"paragraph"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
690 and C are parents of commit node A. Parent commits are ordered
691 left-to-right.
</p></div>
692 <div class=
"literalblock">
693 <div class=
"content">
705 <div class=
"literalblock">
706 <div class=
"content">
710 D = A^^ = A^
1^
1 = A~
2
713 G = A^^^ = A^
1^
1^
1 = A~
3
714 H = D^
2 = B^^
2 = A^^^
2 = A~
2^
2
715 I = F^ = B^
3^ = A^^
3^
716 J = F^
2 = B^
3^
2 = A^^
3^
2</tt></pre>
719 <h2 id=
"_specifying_ranges">SPECIFYING RANGES
</h2>
720 <div class=
"sectionbody">
721 <div class=
"paragraph"><p>History traversing commands such as
<tt>git log
</tt> operate on a set
722 of commits, not just a single commit. To these commands,
723 specifying a single revision with the notation described in the
724 previous section means the set of commits reachable from that
725 commit, following the commit ancestry chain.
</p></div>
726 <div class=
"paragraph"><p>To exclude commits reachable from a commit, a prefix
<em>^</em>
727 notation is used. E.g.
<em>^r1 r2
</em> means commits reachable
728 from
<em>r2
</em> but exclude the ones reachable from
<em>r1
</em>.
</p></div>
729 <div class=
"paragraph"><p>This set operation appears so often that there is a shorthand
730 for it. When you have two commits
<em>r1
</em> and
<em>r2
</em> (named according
731 to the syntax explained in SPECIFYING REVISIONS above), you can ask
732 for commits that are reachable from r2 excluding those that are reachable
733 from r1 by
<em>^r1 r2
</em> and it can be written as
<em>r1..r2
</em>.
</p></div>
734 <div class=
"paragraph"><p>A similar notation
<em>r1...r2
</em> is called symmetric difference
735 of
<em>r1
</em> and
<em>r2
</em> and is defined as
736 <em>r1 r2 --not $(git merge-base --all r1 r2)
</em>.
737 It is the set of commits that are reachable from either one of
738 <em>r1
</em> or
<em>r2
</em> but not from both.
</p></div>
739 <div class=
"paragraph"><p>Two other shorthands for naming a set that is formed by a commit
740 and its parent commits exist. The
<em>r1
^@
</em> notation means all
741 parents of
<em>r1
</em>.
<em>r1
^!
</em> includes commit
<em>r1
</em> but excludes
742 all of its parents.
</p></div>
743 <div class=
"paragraph"><p>Here are a handful of examples:
</p></div>
744 <div class=
"literalblock">
745 <div class=
"content">
753 F^! D G H D F
</tt></pre>
756 <h2 id=
"_see_also">SEE ALSO
</h2>
757 <div class=
"sectionbody">
758 <div class=
"paragraph"><p><a href=
"git-rev-parse.html">git-rev-parse(
1)
</a></p></div>
760 <h2 id=
"_git">GIT
</h2>
761 <div class=
"sectionbody">
762 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
765 <div id=
"footer-text">
766 Last updated
2010-
07-
15 22:
23:
57 UTC