Autogenerated HTML docs for v1.7.6-549-gf85a0
[git/jnareb-git.git] / git-rev-parse.html
blobf42163485e348184aac8ac78849007af7ca88f73
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.4.5" />
7 <title>git-rev-parse(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.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 {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
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 {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
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;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-rev-parse(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-rev-parse -
411 Pick out and massage parameters
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git rev-parse</em> [ --option ] &lt;args&gt;&#8230;</div>
419 <div class="verseblock-attribution">
420 </div></div>
421 </div>
422 <h2 id="_description">DESCRIPTION</h2>
423 <div class="sectionbody">
424 <div class="paragraph"><p>Many git porcelainish commands take mixture of flags
425 (i.e. parameters that begin with a dash <em>-</em>) and parameters
426 meant for the underlying <em>git rev-list</em> command they use internally
427 and flags and parameters for the other commands they use
428 downstream of <em>git rev-list</em>. This command is used to
429 distinguish between them.</p></div>
430 </div>
431 <h2 id="_options">OPTIONS</h2>
432 <div class="sectionbody">
433 <div class="dlist"><dl>
434 <dt class="hdlist1">
435 --parseopt
436 </dt>
437 <dd>
439 Use <em>git rev-parse</em> in option parsing mode (see PARSEOPT section below).
440 </p>
441 </dd>
442 <dt class="hdlist1">
443 --keep-dashdash
444 </dt>
445 <dd>
447 Only meaningful in <tt>--parseopt</tt> mode. Tells the option parser to echo
448 out the first <tt>--</tt> met instead of skipping it.
449 </p>
450 </dd>
451 <dt class="hdlist1">
452 --stop-at-non-option
453 </dt>
454 <dd>
456 Only meaningful in <tt>--parseopt</tt> mode. Lets the option parser stop at
457 the first non-option argument. This can be used to parse sub-commands
458 that take options themselves.
459 </p>
460 </dd>
461 <dt class="hdlist1">
462 --sq-quote
463 </dt>
464 <dd>
466 Use <em>git rev-parse</em> in shell quoting mode (see SQ-QUOTE
467 section below). In contrast to the <tt>--sq</tt> option below, this
468 mode does only quoting. Nothing else is done to command input.
469 </p>
470 </dd>
471 <dt class="hdlist1">
472 --revs-only
473 </dt>
474 <dd>
476 Do not output flags and parameters not meant for
477 <em>git rev-list</em> command.
478 </p>
479 </dd>
480 <dt class="hdlist1">
481 --no-revs
482 </dt>
483 <dd>
485 Do not output flags and parameters meant for
486 <em>git rev-list</em> command.
487 </p>
488 </dd>
489 <dt class="hdlist1">
490 --flags
491 </dt>
492 <dd>
494 Do not output non-flag parameters.
495 </p>
496 </dd>
497 <dt class="hdlist1">
498 --no-flags
499 </dt>
500 <dd>
502 Do not output flag parameters.
503 </p>
504 </dd>
505 <dt class="hdlist1">
506 --default &lt;arg&gt;
507 </dt>
508 <dd>
510 If there is no parameter given by the user, use <tt>&lt;arg&gt;</tt>
511 instead.
512 </p>
513 </dd>
514 <dt class="hdlist1">
515 --verify
516 </dt>
517 <dd>
519 The parameter given must be usable as a single, valid
520 object name. Otherwise barf and abort.
521 </p>
522 </dd>
523 <dt class="hdlist1">
525 </dt>
526 <dt class="hdlist1">
527 --quiet
528 </dt>
529 <dd>
531 Only meaningful in <tt>--verify</tt> mode. Do not output an error
532 message if the first argument is not a valid object name;
533 instead exit with non-zero status silently.
534 </p>
535 </dd>
536 <dt class="hdlist1">
537 --sq
538 </dt>
539 <dd>
541 Usually the output is made one line per flag and
542 parameter. This option makes output a single line,
543 properly quoted for consumption by shell. Useful when
544 you expect your parameter to contain whitespaces and
545 newlines (e.g. when using pickaxe <tt>-S</tt> with
546 <em>git diff-&#42;</em>). In contrast to the <tt>--sq-quote</tt> option,
547 the command input is still interpreted as usual.
548 </p>
549 </dd>
550 <dt class="hdlist1">
551 --not
552 </dt>
553 <dd>
555 When showing object names, prefix them with <em>&#94;</em> and
556 strip <em>&#94;</em> prefix from the object names that already have
557 one.
558 </p>
559 </dd>
560 <dt class="hdlist1">
561 --symbolic
562 </dt>
563 <dd>
565 Usually the object names are output in SHA1 form (with
566 possible <em>&#94;</em> prefix); this option makes them output in a
567 form as close to the original input as possible.
568 </p>
569 </dd>
570 <dt class="hdlist1">
571 --symbolic-full-name
572 </dt>
573 <dd>
575 This is similar to --symbolic, but it omits input that
576 are not refs (i.e. branch or tag names; or more
577 explicitly disambiguating "heads/master" form, when you
578 want to name the "master" branch when there is an
579 unfortunately named tag "master"), and show them as full
580 refnames (e.g. "refs/heads/master").
581 </p>
582 </dd>
583 <dt class="hdlist1">
584 --abbrev-ref[=(strict|loose)]
585 </dt>
586 <dd>
588 A non-ambiguous short name of the objects name.
589 The option core.warnAmbiguousRefs is used to select the strict
590 abbreviation mode.
591 </p>
592 </dd>
593 <dt class="hdlist1">
594 --all
595 </dt>
596 <dd>
598 Show all refs found in <tt>refs/</tt>.
599 </p>
600 </dd>
601 <dt class="hdlist1">
602 --branches[=pattern]
603 </dt>
604 <dt class="hdlist1">
605 --tags[=pattern]
606 </dt>
607 <dt class="hdlist1">
608 --remotes[=pattern]
609 </dt>
610 <dd>
612 Show all branches, tags, or remote-tracking branches,
613 respectively (i.e., refs found in <tt>refs/heads</tt>,
614 <tt>refs/tags</tt>, or <tt>refs/remotes</tt>, respectively).
615 </p>
616 <div class="paragraph"><p>If a <tt>pattern</tt> is given, only refs matching the given shell glob are
617 shown. If the pattern does not contain a globbing character (<tt>?</tt>,
618 <tt>&#42;</tt>, or <tt>[</tt>), it is turned into a prefix match by
619 appending <tt>/&#42;</tt>.</p></div>
620 </dd>
621 <dt class="hdlist1">
622 --glob=pattern
623 </dt>
624 <dd>
626 Show all refs matching the shell glob pattern <tt>pattern</tt>. If
627 the pattern does not start with <tt>refs/</tt>, this is automatically
628 prepended. If the pattern does not contain a globbing
629 character (<tt>?</tt>, <tt>&#42;</tt>, or <tt>[</tt>), it is turned into a prefix
630 match by appending <tt>/&#42;</tt>.
631 </p>
632 </dd>
633 <dt class="hdlist1">
634 --show-toplevel
635 </dt>
636 <dd>
638 Show the absolute path of the top-level directory.
639 </p>
640 </dd>
641 <dt class="hdlist1">
642 --show-prefix
643 </dt>
644 <dd>
646 When the command is invoked from a subdirectory, show the
647 path of the current directory relative to the top-level
648 directory.
649 </p>
650 </dd>
651 <dt class="hdlist1">
652 --show-cdup
653 </dt>
654 <dd>
656 When the command is invoked from a subdirectory, show the
657 path of the top-level directory relative to the current
658 directory (typically a sequence of "../", or an empty string).
659 </p>
660 </dd>
661 <dt class="hdlist1">
662 --git-dir
663 </dt>
664 <dd>
666 Show <tt>$GIT_DIR</tt> if defined. Otherwise show the path to
667 the .git directory, relative to the current directory.
668 </p>
669 <div class="paragraph"><p>If <tt>$GIT_DIR</tt> is not defined and the current directory
670 is not detected to lie in a git repository or work tree
671 print a message to stderr and exit with nonzero status.</p></div>
672 </dd>
673 <dt class="hdlist1">
674 --is-inside-git-dir
675 </dt>
676 <dd>
678 When the current working directory is below the repository
679 directory print "true", otherwise "false".
680 </p>
681 </dd>
682 <dt class="hdlist1">
683 --is-inside-work-tree
684 </dt>
685 <dd>
687 When the current working directory is inside the work tree of the
688 repository print "true", otherwise "false".
689 </p>
690 </dd>
691 <dt class="hdlist1">
692 --is-bare-repository
693 </dt>
694 <dd>
696 When the repository is bare print "true", otherwise "false".
697 </p>
698 </dd>
699 <dt class="hdlist1">
700 --local-env-vars
701 </dt>
702 <dd>
704 List the GIT_* environment variables that are local to the
705 repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
706 Only the names of the variables are listed, not their value,
707 even if they are set.
708 </p>
709 </dd>
710 <dt class="hdlist1">
711 --short
712 </dt>
713 <dt class="hdlist1">
714 --short=number
715 </dt>
716 <dd>
718 Instead of outputting the full SHA1 values of object names try to
719 abbreviate them to a shorter unique name. When no length is specified
720 7 is used. The minimum length is 4.
721 </p>
722 </dd>
723 <dt class="hdlist1">
724 --since=datestring
725 </dt>
726 <dt class="hdlist1">
727 --after=datestring
728 </dt>
729 <dd>
731 Parse the date string, and output the corresponding
732 --max-age= parameter for <em>git rev-list</em>.
733 </p>
734 </dd>
735 <dt class="hdlist1">
736 --until=datestring
737 </dt>
738 <dt class="hdlist1">
739 --before=datestring
740 </dt>
741 <dd>
743 Parse the date string, and output the corresponding
744 --min-age= parameter for <em>git rev-list</em>.
745 </p>
746 </dd>
747 <dt class="hdlist1">
748 &lt;args&gt;&#8230;
749 </dt>
750 <dd>
752 Flags and parameters to be parsed.
753 </p>
754 </dd>
755 </dl></div>
756 </div>
757 <h2 id="_specifying_revisions">SPECIFYING REVISIONS</h2>
758 <div class="sectionbody">
759 <div class="paragraph"><p>A revision parameter <em>&lt;rev&gt;</em> typically, but not necessarily, names a
760 commit object. It uses what is called an <em>extended SHA1</em>
761 syntax. Here are various ways to spell object names. The
762 ones listed near the end of this list name trees and
763 blobs contained in a commit.</p></div>
764 <div class="dlist"><dl>
765 <dt class="hdlist1">
766 <em>&lt;sha1&gt;</em>, e.g. <em>dae86e1950b1277e545cee180551750029cfe735</em>, <em>dae86e</em>
767 </dt>
768 <dd>
770 The full SHA1 object name (40-byte hexadecimal string), or
771 a leading substring that is unique within the repository.
772 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
773 name the same commit object if there is no other object in
774 your repository whose object name starts with dae86e.
775 </p>
776 </dd>
777 <dt class="hdlist1">
778 <em>&lt;describeOutput&gt;</em>, e.g. <em>v1.7.4.2-679-g3bee7fb</em>
779 </dt>
780 <dd>
782 Output from <tt>git describe</tt>; i.e. a closest tag, optionally
783 followed by a dash and a number of commits, followed by a dash, a
784 <em>g</em>, and an abbreviated object name.
785 </p>
786 </dd>
787 <dt class="hdlist1">
788 <em>&lt;refname&gt;</em>, e.g. <em>master</em>, <em>heads/master</em>, <em>refs/heads/master</em>
789 </dt>
790 <dd>
792 A symbolic ref name. E.g. <em>master</em> typically means the commit
793 object referenced by <em>refs/heads/master</em>. If you
794 happen to have both <em>heads/master</em> and <em>tags/master</em>, you can
795 explicitly say <em>heads/master</em> to tell git which one you mean.
796 When ambiguous, a <em>&lt;name&gt;</em> is disambiguated by taking the
797 first match in the following rules:
798 </p>
799 <div class="olist arabic"><ol class="arabic">
800 <li>
802 If <em>$GIT_DIR/&lt;name&gt;</em> exists, that is what you mean (this is usually
803 useful only for <em>HEAD</em>, <em>FETCH_HEAD</em>, <em>ORIG_HEAD</em>, <em>MERGE_HEAD</em>
804 and <em>CHERRY_PICK_HEAD</em>);
805 </p>
806 </li>
807 <li>
809 otherwise, <em>refs/&lt;name&gt;</em> if it exists;
810 </p>
811 </li>
812 <li>
814 otherwise, <em>refs/tags/&lt;refname&gt;</em> if it exists;
815 </p>
816 </li>
817 <li>
819 otherwise, <em>refs/heads/&lt;name&gt;</em> if it exists;
820 </p>
821 </li>
822 <li>
824 otherwise, <em>refs/remotes/&lt;name&gt;</em> if it exists;
825 </p>
826 </li>
827 <li>
829 otherwise, <em>refs/remotes/&lt;name&gt;/HEAD</em> if it exists.
830 </p>
831 <div class="paragraph"><p><em>HEAD</em> names the commit on which you based the changes in the working tree.
832 <em>FETCH_HEAD</em> records the branch which you fetched from a remote repository
833 with your last <tt>git fetch</tt> invocation.
834 <em>ORIG_HEAD</em> is created by commands that move your <em>HEAD</em> in a drastic
835 way, to record the position of the <em>HEAD</em> before their operation, so that
836 you can easily change the tip of the branch back to the state before you ran
837 them.
838 <em>MERGE_HEAD</em> records the commit(s) which you are merging into your branch
839 when you run <tt>git merge</tt>.
840 <em>CHERRY_PICK_HEAD</em> records the commit which you are cherry-picking
841 when you run <tt>git cherry-pick</tt>.</p></div>
842 <div class="paragraph"><p>Note that any of the <em>refs/*</em> cases above may come either from
843 the <em>$GIT_DIR/refs</em> directory or from the <em>$GIT_DIR/packed-refs</em> file.</p></div>
844 </li>
845 </ol></div>
846 </dd>
847 <dt class="hdlist1">
848 <em>&lt;refname&gt;@{&lt;date&gt;}</em>, e.g. <em>master@{yesterday}</em>, <em>HEAD@{5 minutes ago}</em>
849 </dt>
850 <dd>
852 A ref followed by the suffix <em>@</em> with a date specification
853 enclosed in a brace
854 pair (e.g. <em>{yesterday}</em>, <em>{1 month 2 weeks 3 days 1 hour 1
855 second ago}</em> or <em>{1979-02-26 18:30:00}</em>) specifies the value
856 of the ref at a prior point in time. This suffix may only be
857 used immediately following a ref name and the ref must have an
858 existing log (<em>$GIT_DIR/logs/&lt;ref&gt;</em>). Note that this looks up the state
859 of your <strong>local</strong> ref at a given time; e.g., what was in your local
860 <em>master</em> branch last week. If you want to look at commits made during
861 certain times, see <em>--since</em> and <em>--until</em>.
862 </p>
863 </dd>
864 <dt class="hdlist1">
865 <em>&lt;refname&gt;@{&lt;n&gt;}</em>, e.g. <em>master@{1}</em>
866 </dt>
867 <dd>
869 A ref followed by the suffix <em>@</em> with an ordinal specification
870 enclosed in a brace pair (e.g. <em>{1}</em>, <em>{15}</em>) specifies
871 the n-th prior value of that ref. For example <em>master@{1}</em>
872 is the immediate prior value of <em>master</em> while <em>master@{5}</em>
873 is the 5th prior value of <em>master</em>. This suffix may only be used
874 immediately following a ref name and the ref must have an existing
875 log (<em>$GIT_DIR/logs/&lt;refname&gt;</em>).
876 </p>
877 </dd>
878 <dt class="hdlist1">
879 <em>@{&lt;n&gt;}</em>, e.g. <em>@{1}</em>
880 </dt>
881 <dd>
883 You can use the <em>@</em> construct with an empty ref part to get at a
884 reflog entry of the current branch. For example, if you are on
885 branch <em>blabla</em> then <em>@{1}</em> means the same as <em>blabla@{1}</em>.
886 </p>
887 </dd>
888 <dt class="hdlist1">
889 <em>@{-&lt;n&gt;}</em>, e.g. <em>@{-1}</em>
890 </dt>
891 <dd>
893 The construct <em>@{-&lt;n&gt;}</em> means the &lt;n&gt;th branch checked out
894 before the current one.
895 </p>
896 </dd>
897 <dt class="hdlist1">
898 <em>&lt;refname&gt;@{upstream}</em>, e.g. <em>master@{upstream}</em>, <em>@{u}</em>
899 </dt>
900 <dd>
902 The suffix <em>@{upstream}</em> to a ref (short form <em>&lt;refname&gt;@{u}</em>) refers to
903 the branch the ref is set to build on top of. A missing ref defaults
904 to the current branch.
905 </p>
906 </dd>
907 <dt class="hdlist1">
908 <em>&lt;rev&gt;&#94;</em>, e.g. <em>HEAD&#94;, v1.5.1&#94;0</em>
909 </dt>
910 <dd>
912 A suffix <em>&#94;</em> to a revision parameter means the first parent of
913 that commit object. <em>&#94;&lt;n&gt;</em> means the &lt;n&gt;th parent (i.e.
914 <em>&lt;rev&gt;&#94;</em>
915 is equivalent to <em>&lt;rev&gt;&#94;1</em>). As a special rule,
916 <em>&lt;rev&gt;&#94;0</em> means the commit itself and is used when <em>&lt;rev&gt;</em> is the
917 object name of a tag object that refers to a commit object.
918 </p>
919 </dd>
920 <dt class="hdlist1">
921 <em>&lt;rev&gt;&#126;&lt;n&gt;</em>, e.g. <em>master&#126;3</em>
922 </dt>
923 <dd>
925 A suffix <em>&#126;&lt;n&gt;</em> to a revision parameter means the commit
926 object that is the &lt;n&gt;th generation grand-parent of the named
927 commit object, following only the first parents. I.e. <em>&lt;rev&gt;&#126;3</em> is
928 equivalent to <em>&lt;rev&gt;&#94;&#94;&#94;</em> which is equivalent to
929 <em>&lt;rev&gt;&#94;1&#94;1&#94;1</em>. See below for an illustration of
930 the usage of this form.
931 </p>
932 </dd>
933 <dt class="hdlist1">
934 <em>&lt;rev&gt;&#94;{&lt;type&gt;}</em>, e.g. <em>v0.99.8&#94;{commit}</em>
935 </dt>
936 <dd>
938 A suffix <em>&#94;</em> followed by an object type name enclosed in
939 brace pair means the object
940 could be a tag, and dereference the tag recursively until an
941 object of that type is found or the object cannot be
942 dereferenced anymore (in which case, barf). <em>&lt;rev&gt;&#94;0</em>
943 is a short-hand for <em>&lt;rev&gt;&#94;{commit}</em>.
944 </p>
945 </dd>
946 <dt class="hdlist1">
947 <em>&lt;rev&gt;&#94;{}</em>, e.g. <em>v0.99.8&#94;{}</em>
948 </dt>
949 <dd>
951 A suffix <em>&#94;</em> followed by an empty brace pair
952 means the object could be a tag,
953 and dereference the tag recursively until a non-tag object is
954 found.
955 </p>
956 </dd>
957 <dt class="hdlist1">
958 <em>&lt;rev&gt;&#94;{/&lt;text&gt;}</em>, e.g. <em>HEAD^{/fix nasty bug}</em>
959 </dt>
960 <dd>
962 A suffix <em>&#94;</em> to a revision parameter, followed by a brace
963 pair that contains a text led by a slash,
964 is the same as the <em>:/fix nasty bug</em> syntax below except that
965 it returns the youngest matching commit which is reachable from
966 the <em>&lt;rev&gt;</em> before <em>&#94;</em>.
967 </p>
968 </dd>
969 <dt class="hdlist1">
970 <em>:/&lt;text&gt;</em>, e.g. <em>:/fix nasty bug</em>
971 </dt>
972 <dd>
974 A colon, followed by a slash, followed by a text, names
975 a commit whose commit message matches the specified regular expression.
976 This name returns the youngest matching commit which is
977 reachable from any ref. If the commit message starts with a
978 <em>!</em> you have to repeat that; the special sequence <em>:/!</em>,
979 followed by something else than <em>!</em>, is reserved for now.
980 The regular expression can match any part of the commit message. To
981 match messages starting with a string, one can use e.g. <em>:/^foo</em>.
982 </p>
983 </dd>
984 <dt class="hdlist1">
985 <em>&lt;rev&gt;:&lt;path&gt;</em>, e.g. <em>HEAD:README</em>, <em>:README</em>, <em>master:./README</em>
986 </dt>
987 <dd>
989 A suffix <em>:</em> followed by a path names the blob or tree
990 at the given path in the tree-ish object named by the part
991 before the colon.
992 <em>:path</em> (with an empty part before the colon)
993 is a special case of the syntax described next: content
994 recorded in the index at the given path.
995 A path starting with <em>./</em> or <em>../</em> is relative to the current working directory.
996 The given path will be converted to be relative to the working tree&#8217;s root directory.
997 This is most useful to address a blob or tree from a commit or tree that has
998 the same tree structure as the working tree.
999 </p>
1000 </dd>
1001 <dt class="hdlist1">
1002 <em>:&lt;n&gt;:&lt;path&gt;</em>, e.g. <em>:0:README</em>, <em>:README</em>
1003 </dt>
1004 <dd>
1006 A colon, optionally followed by a stage number (0 to 3) and a
1007 colon, followed by a path, names a blob object in the
1008 index at the given path. A missing stage number (and the colon
1009 that follows it) names a stage 0 entry. During a merge, stage
1010 1 is the common ancestor, stage 2 is the target branch&#8217;s version
1011 (typically the current branch), and stage 3 is the version from
1012 the branch which is being merged.
1013 </p>
1014 </dd>
1015 </dl></div>
1016 <div class="paragraph"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
1017 and C are parents of commit node A. Parent commits are ordered
1018 left-to-right.</p></div>
1019 <div class="literalblock">
1020 <div class="content">
1021 <pre><tt>G H I J
1022 \ / \ /
1023 D E F
1024 \ | / \
1025 \ | / |
1026 \|/ |
1030 A</tt></pre>
1031 </div></div>
1032 <div class="literalblock">
1033 <div class="content">
1034 <pre><tt>A = = A^0
1035 B = A^ = A^1 = A~1
1036 C = A^2 = A^2
1037 D = A^^ = A^1^1 = A~2
1038 E = B^2 = A^^2
1039 F = B^3 = A^^3
1040 G = A^^^ = A^1^1^1 = A~3
1041 H = D^2 = B^^2 = A^^^2 = A~2^2
1042 I = F^ = B^3^ = A^^3^
1043 J = F^2 = B^3^2 = A^^3^2</tt></pre>
1044 </div></div>
1045 </div>
1046 <h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
1047 <div class="sectionbody">
1048 <div class="paragraph"><p>History traversing commands such as <tt>git log</tt> operate on a set
1049 of commits, not just a single commit. To these commands,
1050 specifying a single revision with the notation described in the
1051 previous section means the set of commits reachable from that
1052 commit, following the commit ancestry chain.</p></div>
1053 <div class="paragraph"><p>To exclude commits reachable from a commit, a prefix <em>&#94;</em>
1054 notation is used. E.g. <em>&#94;r1 r2</em> means commits reachable
1055 from <em>r2</em> but exclude the ones reachable from <em>r1</em>.</p></div>
1056 <div class="paragraph"><p>This set operation appears so often that there is a shorthand
1057 for it. When you have two commits <em>r1</em> and <em>r2</em> (named according
1058 to the syntax explained in SPECIFYING REVISIONS above), you can ask
1059 for commits that are reachable from r2 excluding those that are reachable
1060 from r1 by <em>&#94;r1 r2</em> and it can be written as <em>r1..r2</em>.</p></div>
1061 <div class="paragraph"><p>A similar notation <em>r1...r2</em> is called symmetric difference
1062 of <em>r1</em> and <em>r2</em> and is defined as
1063 <em>r1 r2 --not $(git merge-base --all r1 r2)</em>.
1064 It is the set of commits that are reachable from either one of
1065 <em>r1</em> or <em>r2</em> but not from both.</p></div>
1066 <div class="paragraph"><p>Two other shorthands for naming a set that is formed by a commit
1067 and its parent commits exist. The <em>r1&#94;@</em> notation means all
1068 parents of <em>r1</em>. <em>r1&#94;!</em> includes commit <em>r1</em> but excludes
1069 all of its parents.</p></div>
1070 <div class="paragraph"><p>Here are a handful of examples:</p></div>
1071 <div class="literalblock">
1072 <div class="content">
1073 <pre><tt>D G H D
1074 D F G H I J D F
1075 ^G D H D
1076 ^D B E I J F B
1077 B...C G H D E B C
1078 ^D B C E I J F B C
1079 C^@ I J F
1080 F^! D G H D F</tt></pre>
1081 </div></div>
1082 </div>
1083 <h2 id="_parseopt">PARSEOPT</h2>
1084 <div class="sectionbody">
1085 <div class="paragraph"><p>In <tt>--parseopt</tt> mode, <em>git rev-parse</em> helps massaging options to bring to shell
1086 scripts the same facilities C builtins have. It works as an option normalizer
1087 (e.g. splits single switches aggregate values), a bit like <tt>getopt(1)</tt> does.</p></div>
1088 <div class="paragraph"><p>It takes on the standard input the specification of the options to parse and
1089 understand, and echoes on the standard output a string suitable for <tt>sh(1)</tt> <tt>eval</tt>
1090 to replace the arguments with normalized ones. In case of error, it outputs
1091 usage on the standard error stream, and exits with code 129.</p></div>
1092 <div class="paragraph"><p>Note: Make sure you quote the result when passing it to <tt>eval</tt>. See
1093 below for an example.</p></div>
1094 <h3 id="_input_format">Input Format</h3><div style="clear:left"></div>
1095 <div class="paragraph"><p><em>git rev-parse --parseopt</em> input format is fully text based. It has two parts,
1096 separated by a line that contains only <tt>--</tt>. The lines before the separator
1097 (should be more than one) are used for the usage.
1098 The lines after the separator describe the options.</p></div>
1099 <div class="paragraph"><p>Each line of options has this format:</p></div>
1100 <div class="listingblock">
1101 <div class="content">
1102 <pre><tt>&lt;opt_spec&gt;&lt;flags&gt;* SP+ help LF</tt></pre>
1103 </div></div>
1104 <div class="dlist"><dl>
1105 <dt class="hdlist1">
1106 <tt>&lt;opt_spec&gt;</tt>
1107 </dt>
1108 <dd>
1110 its format is the short option character, then the long option name
1111 separated by a comma. Both parts are not required, though at least one
1112 is necessary. <tt>h,help</tt>, <tt>dry-run</tt> and <tt>f</tt> are all three correct
1113 <tt>&lt;opt_spec&gt;</tt>.
1114 </p>
1115 </dd>
1116 <dt class="hdlist1">
1117 <tt>&lt;flags&gt;</tt>
1118 </dt>
1119 <dd>
1121 <tt>&lt;flags&gt;</tt> are of <tt>*</tt>, <tt>=</tt>, <tt>?</tt> or <tt>!</tt>.
1122 </p>
1123 <div class="ulist"><ul>
1124 <li>
1126 Use <tt>=</tt> if the option takes an argument.
1127 </p>
1128 </li>
1129 <li>
1131 Use <tt>?</tt> to mean that the option is optional (though its use is discouraged).
1132 </p>
1133 </li>
1134 <li>
1136 Use <tt>*</tt> to mean that this option should not be listed in the usage
1137 generated for the <tt>-h</tt> argument. It&#8217;s shown for <tt>--help-all</tt> as
1138 documented in <a href="gitcli.html">gitcli(7)</a>.
1139 </p>
1140 </li>
1141 <li>
1143 Use <tt>!</tt> to not make the corresponding negated long option available.
1144 </p>
1145 </li>
1146 </ul></div>
1147 </dd>
1148 </dl></div>
1149 <div class="paragraph"><p>The remainder of the line, after stripping the spaces, is used
1150 as the help associated to the option.</p></div>
1151 <div class="paragraph"><p>Blank lines are ignored, and lines that don&#8217;t match this specification are used
1152 as option group headers (start the line with a space to create such
1153 lines on purpose).</p></div>
1154 <h3 id="_example">Example</h3><div style="clear:left"></div>
1155 <div class="listingblock">
1156 <div class="content">
1157 <pre><tt>OPTS_SPEC="\
1158 some-command [options] &lt;args&gt;...
1160 some-command does foo and bar!
1162 h,help show the help
1164 foo some nifty option --foo
1165 bar= some cool option --bar with an argument
1167 An option group Header
1168 C? option C with an optional argument"
1170 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"</tt></pre>
1171 </div></div>
1172 </div>
1173 <h2 id="_sq_quote">SQ-QUOTE</h2>
1174 <div class="sectionbody">
1175 <div class="paragraph"><p>In <tt>--sq-quote</tt> mode, <em>git rev-parse</em> echoes on the standard output a
1176 single line suitable for <tt>sh(1)</tt> <tt>eval</tt>. This line is made by
1177 normalizing the arguments following <tt>--sq-quote</tt>. Nothing other than
1178 quoting the arguments is done.</p></div>
1179 <div class="paragraph"><p>If you want command input to still be interpreted as usual by
1180 <em>git rev-parse</em> before the output is shell quoted, see the <tt>--sq</tt>
1181 option.</p></div>
1182 <h3 id="_example_2">Example</h3><div style="clear:left"></div>
1183 <div class="listingblock">
1184 <div class="content">
1185 <pre><tt>$ cat &gt;your-git-script.sh &lt;&lt;\EOF
1186 #!/bin/sh
1187 args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments
1188 command="git frotz -n24 $args" # and use it inside a handcrafted
1189 # command line
1190 eval "$command"
1193 $ sh your-git-script.sh "a b'c"</tt></pre>
1194 </div></div>
1195 </div>
1196 <h2 id="_examples">EXAMPLES</h2>
1197 <div class="sectionbody">
1198 <div class="ulist"><ul>
1199 <li>
1201 Print the object name of the current commit:
1202 </p>
1203 <div class="listingblock">
1204 <div class="content">
1205 <pre><tt>$ git rev-parse --verify HEAD</tt></pre>
1206 </div></div>
1207 </li>
1208 <li>
1210 Print the commit object name from the revision in the $REV shell variable:
1211 </p>
1212 <div class="listingblock">
1213 <div class="content">
1214 <pre><tt>$ git rev-parse --verify $REV</tt></pre>
1215 </div></div>
1216 <div class="paragraph"><p>This will error out if $REV is empty or not a valid revision.</p></div>
1217 </li>
1218 <li>
1220 Same as above:
1221 </p>
1222 <div class="listingblock">
1223 <div class="content">
1224 <pre><tt>$ git rev-parse --default master --verify $REV</tt></pre>
1225 </div></div>
1226 <div class="paragraph"><p>but if $REV is empty, the commit object name from master will be printed.</p></div>
1227 </li>
1228 </ul></div>
1229 </div>
1230 <h2 id="_git">GIT</h2>
1231 <div class="sectionbody">
1232 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1233 </div>
1234 <div id="footer">
1235 <div id="footer-text">
1236 Last updated 2011-07-23 00:49:30 UTC
1237 </div>
1238 </div>
1239 </body>
1240 </html>