Autogenerated HTML docs for v1.7.3.3-402-ga48aa
[git/jnareb-git.git] / gitrevisions.html
blob5d4db53a73e28e398349366ed9e6f7d1255fbac0
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">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>gitrevisions(7)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 gitrevisions(7) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>gitrevisions -
317 specifying revisions and ranges for git
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="para"><p>gitrevisions</p></div>
324 </div>
325 <h2 id="_description">DESCRIPTION</h2>
326 <div class="sectionbody">
327 <div class="para"><p>Many Git commands take revision parameters as arguments. Depending on
328 the command, they denote a specific commit or, for commands which
329 walk the revision graph (such as <a href="git-log.html">git-log(1)</a>), all commits which can
330 be reached from that commit. In the latter case one can also specify a
331 range of revisions explicitly.</p></div>
332 <div class="para"><p>In addition, some Git commands (such as <a href="git-show.html">git-show(1)</a>) also take
333 revision parameters which denote other objects than commits, e.g. blobs
334 ("files") or trees ("directories of files").</p></div>
335 </div>
336 <h2 id="_specifying_revisions">SPECIFYING REVISIONS</h2>
337 <div class="sectionbody">
338 <div class="para"><p>A revision parameter typically, but not necessarily, names a
339 commit object. They use what is called an <em>extended SHA1</em>
340 syntax. Here are various ways to spell object names. The
341 ones listed near the end of this list are to name trees and
342 blobs contained in a commit.</p></div>
343 <div class="ilist"><ul>
344 <li>
346 The full SHA1 object name (40-byte hexadecimal string), or
347 a substring of such that is unique within the repository.
348 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
349 name the same commit object if there are no other object in
350 your repository whose object name starts with dae86e.
351 </p>
352 </li>
353 <li>
355 An output from <em>git describe</em>; i.e. a closest tag, optionally
356 followed by a dash and a number of commits, followed by a dash, a
357 <tt>g</tt>, and an abbreviated object name.
358 </p>
359 </li>
360 <li>
362 A symbolic ref name. E.g. <em>master</em> typically means the commit
363 object referenced by refs/heads/master. If you
364 happen to have both heads/master and tags/master, you can
365 explicitly say <em>heads/master</em> to tell git which one you mean.
366 When ambiguous, a <tt>&lt;name&gt;</tt> is disambiguated by taking the
367 first match in the following rules:
368 </p>
369 <div class="olist"><ol>
370 <li>
372 if <tt>$GIT_DIR/&lt;name&gt;</tt> exists, that is what you mean (this is usually
373 useful only for <tt>HEAD</tt>, <tt>FETCH_HEAD</tt>, <tt>ORIG_HEAD</tt> and <tt>MERGE_HEAD</tt>);
374 </p>
375 </li>
376 <li>
378 otherwise, <tt>refs/&lt;name&gt;</tt> if exists;
379 </p>
380 </li>
381 <li>
383 otherwise, <tt>refs/tags/&lt;name&gt;</tt> if exists;
384 </p>
385 </li>
386 <li>
388 otherwise, <tt>refs/heads/&lt;name&gt;</tt> if exists;
389 </p>
390 </li>
391 <li>
393 otherwise, <tt>refs/remotes/&lt;name&gt;</tt> if exists;
394 </p>
395 </li>
396 <li>
398 otherwise, <tt>refs/remotes/&lt;name&gt;/HEAD</tt> if exists.
399 </p>
400 <div class="para"><p>HEAD names the commit your changes in the working tree is based on.
401 FETCH_HEAD records the branch you fetched from a remote repository
402 with your last <em>git fetch</em> invocation.
403 ORIG_HEAD is created by commands that moves your HEAD in a drastic
404 way, to record the position of the HEAD before their operation, so that
405 you can change the tip of the branch back to the state before you ran
406 them easily.
407 MERGE_HEAD records the commit(s) you are merging into your branch
408 when you run <em>git merge</em>.</p></div>
409 <div class="para"><p>Note that any of the <tt>refs/*</tt> cases above may come either from
410 the <tt>$GIT_DIR/refs</tt> directory or from the <tt>$GIT_DIR/packed-refs</tt> file.</p></div>
411 </li>
412 </ol></div>
413 </li>
414 <li>
416 A ref followed by the suffix <em>@</em> with a date specification
417 enclosed in a brace
418 pair (e.g. <em>{yesterday}</em>, <em>{1 month 2 weeks 3 days 1 hour 1
419 second ago}</em> or <em>{1979-02-26 18:30:00}</em>) to specify the value
420 of the ref at a prior point in time. This suffix may only be
421 used immediately following a ref name and the ref must have an
422 existing log ($GIT_DIR/logs/&lt;ref&gt;). Note that this looks up the state
423 of your <strong>local</strong> ref at a given time; e.g., what was in your local
424 <tt>master</tt> branch last week. If you want to look at commits made during
425 certain times, see <tt>--since</tt> and <tt>--until</tt>.
426 </p>
427 </li>
428 <li>
430 A ref followed by the suffix <em>@</em> with an ordinal specification
431 enclosed in a brace pair (e.g. <em>{1}</em>, <em>{15}</em>) to specify
432 the n-th prior value of that ref. For example <em>master@{1}</em>
433 is the immediate prior value of <em>master</em> while <em>master@{5}</em>
434 is the 5th prior value of <em>master</em>. This suffix may only be used
435 immediately following a ref name and the ref must have an existing
436 log ($GIT_DIR/logs/&lt;ref&gt;).
437 </p>
438 </li>
439 <li>
441 You can use the <em>@</em> construct with an empty ref part to get at a
442 reflog of the current branch. For example, if you are on the
443 branch <em>blabla</em>, then <em>@{1}</em> means the same as <em>blabla@{1}</em>.
444 </p>
445 </li>
446 <li>
448 The special construct <em>@{-&lt;n&gt;}</em> means the &lt;n&gt;th branch checked out
449 before the current one.
450 </p>
451 </li>
452 <li>
454 The suffix <em>@{upstream}</em> to a ref (short form <em>ref@{u}</em>) refers to
455 the branch the ref is set to build on top of. Missing ref defaults
456 to the current branch.
457 </p>
458 </li>
459 <li>
461 A suffix <em>&#94;</em> to a revision parameter (e.g. <em>HEAD&#94;</em>) means the first parent of
462 that commit object. <em>&#94;&lt;n&gt;</em> means the &lt;n&gt;th parent (i.e.
463 <em>rev&#94;</em>
464 is equivalent to <em>rev&#94;1</em>). As a special rule,
465 <em>rev&#94;0</em> means the commit itself and is used when <em>rev</em> is the
466 object name of a tag object that refers to a commit object.
467 </p>
468 </li>
469 <li>
471 A suffix <em>&#126;&lt;n&gt;</em> to a revision parameter means the commit
472 object that is the &lt;n&gt;th generation grand-parent of the named
473 commit object, following only the first parent. I.e. rev~3 is
474 equivalent to rev&#94;&#94;&#94; which is equivalent to
475 rev&#94;1&#94;1&#94;1. See below for a illustration of
476 the usage of this form.
477 </p>
478 </li>
479 <li>
481 A suffix <em>&#94;</em> followed by an object type name enclosed in
482 brace pair (e.g. <tt>v0.99.8&#94;{commit}</tt>) means the object
483 could be a tag, and dereference the tag recursively until an
484 object of that type is found or the object cannot be
485 dereferenced anymore (in which case, barf). <tt>rev&#94;0</tt>
486 introduced earlier is a short-hand for <tt>rev&#94;{commit}</tt>.
487 </p>
488 </li>
489 <li>
491 A suffix <em>&#94;</em> followed by an empty brace pair
492 (e.g. <tt>v0.99.8&#94;{}</tt>) means the object could be a tag,
493 and dereference the tag recursively until a non-tag object is
494 found.
495 </p>
496 </li>
497 <li>
499 A colon, followed by a slash, followed by a text (e.g. <tt>:/fix nasty bug</tt>): this names
500 a commit whose commit message matches the specified regular expression.
501 This name returns the youngest matching commit which is
502 reachable from any ref. If the commit message starts with a
503 <em>!</em>, you have to repeat that; the special sequence <em>:/!</em>,
504 followed by something else than <em>!</em> is reserved for now.
505 The regular expression can match any part of the commit message. To
506 match messages starting with a string, one can use e.g. <tt>:/^foo</tt>.
507 </p>
508 </li>
509 <li>
511 A suffix <em>:</em> followed by a path (e.g. <tt>HEAD:README</tt>); this names the blob or tree
512 at the given path in the tree-ish object named by the part
513 before the colon.
514 <em>:path</em> (with an empty part before the colon, e.g. <tt>:README</tt>)
515 is a special case of the syntax described next: content
516 recorded in the index at the given path.
517 </p>
518 </li>
519 <li>
521 A colon, optionally followed by a stage number (0 to 3) and a
522 colon, followed by a path (e.g. <tt>:0:README</tt>); this names a blob object in the
523 index at the given path. Missing stage number (and the colon
524 that follows it, e.g. <tt>:README</tt>) names a stage 0 entry. During a merge, stage
525 1 is the common ancestor, stage 2 is the target branch's version
526 (typically the current branch), and stage 3 is the version from
527 the branch being merged.
528 </p>
529 </li>
530 </ul></div>
531 <div class="para"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
532 and C are parents of commit node A. Parent commits are ordered
533 left-to-right.</p></div>
534 <div class="literalblock">
535 <div class="content">
536 <pre><tt>G H I J
537 \ / \ /
538 D E F
539 \ | / \
540 \ | / |
541 \|/ |
545 A</tt></pre>
546 </div></div>
547 <div class="literalblock">
548 <div class="content">
549 <pre><tt>A = = A^0
550 B = A^ = A^1 = A~1
551 C = A^2 = A^2
552 D = A^^ = A^1^1 = A~2
553 E = B^2 = A^^2
554 F = B^3 = A^^3
555 G = A^^^ = A^1^1^1 = A~3
556 H = D^2 = B^^2 = A^^^2 = A~2^2
557 I = F^ = B^3^ = A^^3^
558 J = F^2 = B^3^2 = A^^3^2</tt></pre>
559 </div></div>
560 </div>
561 <h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
562 <div class="sectionbody">
563 <div class="para"><p>History traversing commands such as <em>git log</em> operate on a set
564 of commits, not just a single commit. To these commands,
565 specifying a single revision with the notation described in the
566 previous section means the set of commits reachable from that
567 commit, following the commit ancestry chain.</p></div>
568 <div class="para"><p>To exclude commits reachable from a commit, a prefix <tt>&#94;</tt>
569 notation is used. E.g. <tt>&#94;r1 r2</tt> means commits reachable
570 from <tt>r2</tt> but exclude the ones reachable from <tt>r1</tt>.</p></div>
571 <div class="para"><p>This set operation appears so often that there is a shorthand
572 for it. When you have two commits <tt>r1</tt> and <tt>r2</tt> (named according
573 to the syntax explained in SPECIFYING REVISIONS above), you can ask
574 for commits that are reachable from r2 excluding those that are reachable
575 from r1 by <tt>&#94;r1 r2</tt> and it can be written as <tt>r1..r2</tt>.</p></div>
576 <div class="para"><p>A similar notation <tt>r1...r2</tt> is called symmetric difference
577 of <tt>r1</tt> and <tt>r2</tt> and is defined as
578 <tt>r1 r2 --not $(git merge-base --all r1 r2)</tt>.
579 It is the set of commits that are reachable from either one of
580 <tt>r1</tt> or <tt>r2</tt> but not from both.</p></div>
581 <div class="para"><p>Two other shorthands for naming a set that is formed by a commit
582 and its parent commits exist. The <tt>r1&#94;@</tt> notation means all
583 parents of <tt>r1</tt>. <tt>r1&#94;!</tt> includes commit <tt>r1</tt> but excludes
584 all of its parents.</p></div>
585 <div class="para"><p>Here are a handful of examples:</p></div>
586 <div class="literalblock">
587 <div class="content">
588 <pre><tt>D G H D
589 D F G H I J D F
590 ^G D H D
591 ^D B E I J F B
592 B...C G H D E B C
593 ^D B C E I J F B C
594 C^@ I J F
595 F^! D G H D F</tt></pre>
596 </div></div>
597 </div>
598 <h2 id="_see_also">SEE ALSO</h2>
599 <div class="sectionbody">
600 <div class="para"><p><a href="git-rev-parse.html">git-rev-parse(1)</a></p></div>
601 </div>
602 <h2 id="_git">GIT</h2>
603 <div class="sectionbody">
604 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
605 </div>
606 <div id="footer">
607 <div id="footer-text">
608 Last updated 2010-09-28 05:49:38 UTC
609 </div>
610 </div>
611 </body>
612 </html>