Autogenerated HTML docs for v1.7.4.1-266-ga62ea
[git/jnareb-git.git] / git-rev-parse.html
blob72beaec20d9f83cd771c610f0b08e2694be65860
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="paragraph"><p><em>git rev-parse</em> [ --option ] &lt;args&gt;&#8230;</p></div>
418 </div>
419 <h2 id="_description">DESCRIPTION</h2>
420 <div class="sectionbody">
421 <div class="paragraph"><p>Many git porcelainish commands take mixture of flags
422 (i.e. parameters that begin with a dash <em>-</em>) and parameters
423 meant for the underlying <em>git rev-list</em> command they use internally
424 and flags and parameters for the other commands they use
425 downstream of <em>git rev-list</em>. This command is used to
426 distinguish between them.</p></div>
427 </div>
428 <h2 id="_options">OPTIONS</h2>
429 <div class="sectionbody">
430 <div class="dlist"><dl>
431 <dt class="hdlist1">
432 --parseopt
433 </dt>
434 <dd>
436 Use <em>git rev-parse</em> in option parsing mode (see PARSEOPT section below).
437 </p>
438 </dd>
439 <dt class="hdlist1">
440 --keep-dashdash
441 </dt>
442 <dd>
444 Only meaningful in <tt>--parseopt</tt> mode. Tells the option parser to echo
445 out the first <tt>--</tt> met instead of skipping it.
446 </p>
447 </dd>
448 <dt class="hdlist1">
449 --stop-at-non-option
450 </dt>
451 <dd>
453 Only meaningful in <tt>--parseopt</tt> mode. Lets the option parser stop at
454 the first non-option argument. This can be used to parse sub-commands
455 that take options themselves.
456 </p>
457 </dd>
458 <dt class="hdlist1">
459 --sq-quote
460 </dt>
461 <dd>
463 Use <em>git rev-parse</em> in shell quoting mode (see SQ-QUOTE
464 section below). In contrast to the <tt>--sq</tt> option below, this
465 mode does only quoting. Nothing else is done to command input.
466 </p>
467 </dd>
468 <dt class="hdlist1">
469 --revs-only
470 </dt>
471 <dd>
473 Do not output flags and parameters not meant for
474 <em>git rev-list</em> command.
475 </p>
476 </dd>
477 <dt class="hdlist1">
478 --no-revs
479 </dt>
480 <dd>
482 Do not output flags and parameters meant for
483 <em>git rev-list</em> command.
484 </p>
485 </dd>
486 <dt class="hdlist1">
487 --flags
488 </dt>
489 <dd>
491 Do not output non-flag parameters.
492 </p>
493 </dd>
494 <dt class="hdlist1">
495 --no-flags
496 </dt>
497 <dd>
499 Do not output flag parameters.
500 </p>
501 </dd>
502 <dt class="hdlist1">
503 --default &lt;arg&gt;
504 </dt>
505 <dd>
507 If there is no parameter given by the user, use <tt>&lt;arg&gt;</tt>
508 instead.
509 </p>
510 </dd>
511 <dt class="hdlist1">
512 --verify
513 </dt>
514 <dd>
516 The parameter given must be usable as a single, valid
517 object name. Otherwise barf and abort.
518 </p>
519 </dd>
520 <dt class="hdlist1">
522 </dt>
523 <dt class="hdlist1">
524 --quiet
525 </dt>
526 <dd>
528 Only meaningful in <tt>--verify</tt> mode. Do not output an error
529 message if the first argument is not a valid object name;
530 instead exit with non-zero status silently.
531 </p>
532 </dd>
533 <dt class="hdlist1">
534 --sq
535 </dt>
536 <dd>
538 Usually the output is made one line per flag and
539 parameter. This option makes output a single line,
540 properly quoted for consumption by shell. Useful when
541 you expect your parameter to contain whitespaces and
542 newlines (e.g. when using pickaxe <tt>-S</tt> with
543 <em>git diff-&#42;</em>). In contrast to the <tt>--sq-quote</tt> option,
544 the command input is still interpreted as usual.
545 </p>
546 </dd>
547 <dt class="hdlist1">
548 --not
549 </dt>
550 <dd>
552 When showing object names, prefix them with <em>&#94;</em> and
553 strip <em>&#94;</em> prefix from the object names that already have
554 one.
555 </p>
556 </dd>
557 <dt class="hdlist1">
558 --symbolic
559 </dt>
560 <dd>
562 Usually the object names are output in SHA1 form (with
563 possible <em>&#94;</em> prefix); this option makes them output in a
564 form as close to the original input as possible.
565 </p>
566 </dd>
567 <dt class="hdlist1">
568 --symbolic-full-name
569 </dt>
570 <dd>
572 This is similar to --symbolic, but it omits input that
573 are not refs (i.e. branch or tag names; or more
574 explicitly disambiguating "heads/master" form, when you
575 want to name the "master" branch when there is an
576 unfortunately named tag "master"), and show them as full
577 refnames (e.g. "refs/heads/master").
578 </p>
579 </dd>
580 <dt class="hdlist1">
581 --abbrev-ref[=(strict|loose)]
582 </dt>
583 <dd>
585 A non-ambiguous short name of the objects name.
586 The option core.warnAmbiguousRefs is used to select the strict
587 abbreviation mode.
588 </p>
589 </dd>
590 <dt class="hdlist1">
591 --all
592 </dt>
593 <dd>
595 Show all refs found in <tt>refs/</tt>.
596 </p>
597 </dd>
598 <dt class="hdlist1">
599 --branches[=pattern]
600 </dt>
601 <dt class="hdlist1">
602 --tags[=pattern]
603 </dt>
604 <dt class="hdlist1">
605 --remotes[=pattern]
606 </dt>
607 <dd>
609 Show all branches, tags, or remote-tracking branches,
610 respectively (i.e., refs found in <tt>refs/heads</tt>,
611 <tt>refs/tags</tt>, or <tt>refs/remotes</tt>, respectively).
612 </p>
613 <div class="paragraph"><p>If a <tt>pattern</tt> is given, only refs matching the given shell glob are
614 shown. If the pattern does not contain a globbing character (<tt>?</tt>,
615 <tt>&#42;</tt>, or <tt>[</tt>), it is turned into a prefix match by
616 appending <tt>/&#42;</tt>.</p></div>
617 </dd>
618 <dt class="hdlist1">
619 --glob=pattern
620 </dt>
621 <dd>
623 Show all refs matching the shell glob pattern <tt>pattern</tt>. If
624 the pattern does not start with <tt>refs/</tt>, this is automatically
625 prepended. If the pattern does not contain a globbing
626 character (<tt>?</tt>, <tt>&#42;</tt>, or <tt>[</tt>), it is turned into a prefix
627 match by appending <tt>/&#42;</tt>.
628 </p>
629 </dd>
630 <dt class="hdlist1">
631 --show-toplevel
632 </dt>
633 <dd>
635 Show the absolute path of the top-level directory.
636 </p>
637 </dd>
638 <dt class="hdlist1">
639 --show-prefix
640 </dt>
641 <dd>
643 When the command is invoked from a subdirectory, show the
644 path of the current directory relative to the top-level
645 directory.
646 </p>
647 </dd>
648 <dt class="hdlist1">
649 --show-cdup
650 </dt>
651 <dd>
653 When the command is invoked from a subdirectory, show the
654 path of the top-level directory relative to the current
655 directory (typically a sequence of "../", or an empty string).
656 </p>
657 </dd>
658 <dt class="hdlist1">
659 --git-dir
660 </dt>
661 <dd>
663 Show <tt>$GIT_DIR</tt> if defined. Otherwise show the path to
664 the .git directory, relative to the current directory.
665 </p>
666 <div class="paragraph"><p>If <tt>$GIT_DIR</tt> is not defined and the current directory
667 is not detected to lie in a git repository or work tree
668 print a message to stderr and exit with nonzero status.</p></div>
669 </dd>
670 <dt class="hdlist1">
671 --is-inside-git-dir
672 </dt>
673 <dd>
675 When the current working directory is below the repository
676 directory print "true", otherwise "false".
677 </p>
678 </dd>
679 <dt class="hdlist1">
680 --is-inside-work-tree
681 </dt>
682 <dd>
684 When the current working directory is inside the work tree of the
685 repository print "true", otherwise "false".
686 </p>
687 </dd>
688 <dt class="hdlist1">
689 --is-bare-repository
690 </dt>
691 <dd>
693 When the repository is bare print "true", otherwise "false".
694 </p>
695 </dd>
696 <dt class="hdlist1">
697 --local-env-vars
698 </dt>
699 <dd>
701 List the GIT_* environment variables that are local to the
702 repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
703 Only the names of the variables are listed, not their value,
704 even if they are set.
705 </p>
706 </dd>
707 <dt class="hdlist1">
708 --short
709 </dt>
710 <dt class="hdlist1">
711 --short=number
712 </dt>
713 <dd>
715 Instead of outputting the full SHA1 values of object names try to
716 abbreviate them to a shorter unique name. When no length is specified
717 7 is used. The minimum length is 4.
718 </p>
719 </dd>
720 <dt class="hdlist1">
721 --since=datestring
722 </dt>
723 <dt class="hdlist1">
724 --after=datestring
725 </dt>
726 <dd>
728 Parse the date string, and output the corresponding
729 --max-age= parameter for <em>git rev-list</em>.
730 </p>
731 </dd>
732 <dt class="hdlist1">
733 --until=datestring
734 </dt>
735 <dt class="hdlist1">
736 --before=datestring
737 </dt>
738 <dd>
740 Parse the date string, and output the corresponding
741 --min-age= parameter for <em>git rev-list</em>.
742 </p>
743 </dd>
744 <dt class="hdlist1">
745 &lt;args&gt;&#8230;
746 </dt>
747 <dd>
749 Flags and parameters to be parsed.
750 </p>
751 </dd>
752 </dl></div>
753 </div>
754 <h2 id="_specifying_revisions">SPECIFYING REVISIONS</h2>
755 <div class="sectionbody">
756 <div class="paragraph"><p>A revision parameter typically, but not necessarily, names a
757 commit object. They use what is called an <em>extended SHA1</em>
758 syntax. Here are various ways to spell object names. The
759 ones listed near the end of this list are to name trees and
760 blobs contained in a commit.</p></div>
761 <div class="ulist"><ul>
762 <li>
764 The full SHA1 object name (40-byte hexadecimal string), or
765 a substring of such that is unique within the repository.
766 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
767 name the same commit object if there are no other object in
768 your repository whose object name starts with dae86e.
769 </p>
770 </li>
771 <li>
773 An output from <em>git describe</em>; i.e. a closest tag, optionally
774 followed by a dash and a number of commits, followed by a dash, a
775 <tt>g</tt>, and an abbreviated object name.
776 </p>
777 </li>
778 <li>
780 A symbolic ref name. E.g. <em>master</em> typically means the commit
781 object referenced by refs/heads/master. If you
782 happen to have both heads/master and tags/master, you can
783 explicitly say <em>heads/master</em> to tell git which one you mean.
784 When ambiguous, a <tt>&lt;name&gt;</tt> is disambiguated by taking the
785 first match in the following rules:
786 </p>
787 <div class="olist arabic"><ol class="arabic">
788 <li>
790 if <tt>$GIT_DIR/&lt;name&gt;</tt> exists, that is what you mean (this is usually
791 useful only for <tt>HEAD</tt>, <tt>FETCH_HEAD</tt>, <tt>ORIG_HEAD</tt>, <tt>MERGE_HEAD</tt>
792 and <tt>CHERRY_PICK_HEAD</tt>);
793 </p>
794 </li>
795 <li>
797 otherwise, <tt>refs/&lt;name&gt;</tt> if exists;
798 </p>
799 </li>
800 <li>
802 otherwise, <tt>refs/tags/&lt;name&gt;</tt> if exists;
803 </p>
804 </li>
805 <li>
807 otherwise, <tt>refs/heads/&lt;name&gt;</tt> if exists;
808 </p>
809 </li>
810 <li>
812 otherwise, <tt>refs/remotes/&lt;name&gt;</tt> if exists;
813 </p>
814 </li>
815 <li>
817 otherwise, <tt>refs/remotes/&lt;name&gt;/HEAD</tt> if exists.
818 </p>
819 <div class="paragraph"><p>HEAD names the commit your changes in the working tree is based on.
820 FETCH_HEAD records the branch you fetched from a remote repository
821 with your last <em>git fetch</em> invocation.
822 ORIG_HEAD is created by commands that moves your HEAD in a drastic
823 way, to record the position of the HEAD before their operation, so that
824 you can change the tip of the branch back to the state before you ran
825 them easily.
826 MERGE_HEAD records the commit(s) you are merging into your branch
827 when you run <em>git merge</em>.
828 CHERRY_PICK_HEAD records the commit you are cherry-picking
829 when you run <em>git cherry-pick</em>.</p></div>
830 <div class="paragraph"><p>Note that any of the <tt>refs/*</tt> cases above may come either from
831 the <tt>$GIT_DIR/refs</tt> directory or from the <tt>$GIT_DIR/packed-refs</tt> file.</p></div>
832 </li>
833 </ol></div>
834 </li>
835 <li>
837 A ref followed by the suffix <em>@</em> with a date specification
838 enclosed in a brace
839 pair (e.g. <em>{yesterday}</em>, <em>{1 month 2 weeks 3 days 1 hour 1
840 second ago}</em> or <em>{1979-02-26 18:30:00}</em>) to specify the value
841 of the ref at a prior point in time. This suffix may only be
842 used immediately following a ref name and the ref must have an
843 existing log ($GIT_DIR/logs/&lt;ref&gt;). Note that this looks up the state
844 of your <strong>local</strong> ref at a given time; e.g., what was in your local
845 <tt>master</tt> branch last week. If you want to look at commits made during
846 certain times, see <tt>--since</tt> and <tt>--until</tt>.
847 </p>
848 </li>
849 <li>
851 A ref followed by the suffix <em>@</em> with an ordinal specification
852 enclosed in a brace pair (e.g. <em>{1}</em>, <em>{15}</em>) to specify
853 the n-th prior value of that ref. For example <em>master@{1}</em>
854 is the immediate prior value of <em>master</em> while <em>master@{5}</em>
855 is the 5th prior value of <em>master</em>. This suffix may only be used
856 immediately following a ref name and the ref must have an existing
857 log ($GIT_DIR/logs/&lt;ref&gt;).
858 </p>
859 </li>
860 <li>
862 You can use the <em>@</em> construct with an empty ref part to get at a
863 reflog of the current branch. For example, if you are on the
864 branch <em>blabla</em>, then <em>@{1}</em> means the same as <em>blabla@{1}</em>.
865 </p>
866 </li>
867 <li>
869 The special construct <em>@{-&lt;n&gt;}</em> means the &lt;n&gt;th branch checked out
870 before the current one.
871 </p>
872 </li>
873 <li>
875 The suffix <em>@{upstream}</em> to a ref (short form <em>ref@{u}</em>) refers to
876 the branch the ref is set to build on top of. Missing ref defaults
877 to the current branch.
878 </p>
879 </li>
880 <li>
882 A suffix <em>&#94;</em> to a revision parameter (e.g. <em>HEAD&#94;</em>) means the first parent of
883 that commit object. <em>&#94;&lt;n&gt;</em> means the &lt;n&gt;th parent (i.e.
884 <em>rev&#94;</em>
885 is equivalent to <em>rev&#94;1</em>). As a special rule,
886 <em>rev&#94;0</em> means the commit itself and is used when <em>rev</em> is the
887 object name of a tag object that refers to a commit object.
888 </p>
889 </li>
890 <li>
892 A suffix <em>&#126;&lt;n&gt;</em> to a revision parameter means the commit
893 object that is the &lt;n&gt;th generation grand-parent of the named
894 commit object, following only the first parent. I.e. rev~3 is
895 equivalent to rev&#94;&#94;&#94; which is equivalent to
896 rev&#94;1&#94;1&#94;1. See below for a illustration of
897 the usage of this form.
898 </p>
899 </li>
900 <li>
902 A suffix <em>&#94;</em> followed by an object type name enclosed in
903 brace pair (e.g. <tt>v0.99.8&#94;{commit}</tt>) means the object
904 could be a tag, and dereference the tag recursively until an
905 object of that type is found or the object cannot be
906 dereferenced anymore (in which case, barf). <tt>rev&#94;0</tt>
907 introduced earlier is a short-hand for <tt>rev&#94;{commit}</tt>.
908 </p>
909 </li>
910 <li>
912 A suffix <em>&#94;</em> followed by an empty brace pair
913 (e.g. <tt>v0.99.8&#94;{}</tt>) means the object could be a tag,
914 and dereference the tag recursively until a non-tag object is
915 found.
916 </p>
917 </li>
918 <li>
920 A suffix <em>&#94;</em> to a revision parameter followed by a brace
921 pair that contains a text led by a slash (e.g. <tt>HEAD^{/fix nasty bug}</tt>):
922 this is the same as <tt>:/fix nasty bug</tt> syntax below except that
923 it returns the youngest matching commit which is reachable from
924 the ref before <em>&#94;</em>.
925 </p>
926 </li>
927 <li>
929 A colon, followed by a slash, followed by a text (e.g. <tt>:/fix nasty bug</tt>): this names
930 a commit whose commit message matches the specified regular expression.
931 This name returns the youngest matching commit which is
932 reachable from any ref. If the commit message starts with a
933 <em>!</em>, you have to repeat that; the special sequence <em>:/!</em>,
934 followed by something else than <em>!</em> is reserved for now.
935 The regular expression can match any part of the commit message. To
936 match messages starting with a string, one can use e.g. <tt>:/^foo</tt>.
937 </p>
938 </li>
939 <li>
941 A suffix <em>:</em> followed by a path (e.g. <tt>HEAD:README</tt>); this names the blob or tree
942 at the given path in the tree-ish object named by the part
943 before the colon.
944 <em>:path</em> (with an empty part before the colon, e.g. <tt>:README</tt>)
945 is a special case of the syntax described next: content
946 recorded in the index at the given path.
947 A path starting with <em>./</em> or <em>../</em> is relative to current working directory.
948 The given path will be converted to be relative to working tree&#8217;s root directory.
949 This is most useful to address a blob or tree from a commit or tree that has
950 the same tree structure with the working tree.
951 </p>
952 </li>
953 <li>
955 A colon, optionally followed by a stage number (0 to 3) and a
956 colon, followed by a path (e.g. <tt>:0:README</tt>); this names a blob object in the
957 index at the given path. Missing stage number (and the colon
958 that follows it, e.g. <tt>:README</tt>) names a stage 0 entry. During a merge, stage
959 1 is the common ancestor, stage 2 is the target branch&#8217;s version
960 (typically the current branch), and stage 3 is the version from
961 the branch being merged.
962 </p>
963 </li>
964 </ul></div>
965 <div class="paragraph"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
966 and C are parents of commit node A. Parent commits are ordered
967 left-to-right.</p></div>
968 <div class="literalblock">
969 <div class="content">
970 <pre><tt>G H I J
971 \ / \ /
972 D E F
973 \ | / \
974 \ | / |
975 \|/ |
979 A</tt></pre>
980 </div></div>
981 <div class="literalblock">
982 <div class="content">
983 <pre><tt>A = = A^0
984 B = A^ = A^1 = A~1
985 C = A^2 = A^2
986 D = A^^ = A^1^1 = A~2
987 E = B^2 = A^^2
988 F = B^3 = A^^3
989 G = A^^^ = A^1^1^1 = A~3
990 H = D^2 = B^^2 = A^^^2 = A~2^2
991 I = F^ = B^3^ = A^^3^
992 J = F^2 = B^3^2 = A^^3^2</tt></pre>
993 </div></div>
994 </div>
995 <h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
996 <div class="sectionbody">
997 <div class="paragraph"><p>History traversing commands such as <em>git log</em> operate on a set
998 of commits, not just a single commit. To these commands,
999 specifying a single revision with the notation described in the
1000 previous section means the set of commits reachable from that
1001 commit, following the commit ancestry chain.</p></div>
1002 <div class="paragraph"><p>To exclude commits reachable from a commit, a prefix <tt>&#94;</tt>
1003 notation is used. E.g. <tt>&#94;r1 r2</tt> means commits reachable
1004 from <tt>r2</tt> but exclude the ones reachable from <tt>r1</tt>.</p></div>
1005 <div class="paragraph"><p>This set operation appears so often that there is a shorthand
1006 for it. When you have two commits <tt>r1</tt> and <tt>r2</tt> (named according
1007 to the syntax explained in SPECIFYING REVISIONS above), you can ask
1008 for commits that are reachable from r2 excluding those that are reachable
1009 from r1 by <tt>&#94;r1 r2</tt> and it can be written as <tt>r1..r2</tt>.</p></div>
1010 <div class="paragraph"><p>A similar notation <tt>r1...r2</tt> is called symmetric difference
1011 of <tt>r1</tt> and <tt>r2</tt> and is defined as
1012 <tt>r1 r2 --not $(git merge-base --all r1 r2)</tt>.
1013 It is the set of commits that are reachable from either one of
1014 <tt>r1</tt> or <tt>r2</tt> but not from both.</p></div>
1015 <div class="paragraph"><p>Two other shorthands for naming a set that is formed by a commit
1016 and its parent commits exist. The <tt>r1&#94;@</tt> notation means all
1017 parents of <tt>r1</tt>. <tt>r1&#94;!</tt> includes commit <tt>r1</tt> but excludes
1018 all of its parents.</p></div>
1019 <div class="paragraph"><p>Here are a handful of examples:</p></div>
1020 <div class="literalblock">
1021 <div class="content">
1022 <pre><tt>D G H D
1023 D F G H I J D F
1024 ^G D H D
1025 ^D B E I J F B
1026 B...C G H D E B C
1027 ^D B C E I J F B C
1028 C^@ I J F
1029 F^! D G H D F</tt></pre>
1030 </div></div>
1031 </div>
1032 <h2 id="_parseopt">PARSEOPT</h2>
1033 <div class="sectionbody">
1034 <div class="paragraph"><p>In <tt>--parseopt</tt> mode, <em>git rev-parse</em> helps massaging options to bring to shell
1035 scripts the same facilities C builtins have. It works as an option normalizer
1036 (e.g. splits single switches aggregate values), a bit like <tt>getopt(1)</tt> does.</p></div>
1037 <div class="paragraph"><p>It takes on the standard input the specification of the options to parse and
1038 understand, and echoes on the standard output a string suitable for <tt>sh(1)</tt> <tt>eval</tt>
1039 to replace the arguments with normalized ones. In case of error, it outputs
1040 usage on the standard error stream, and exits with code 129.</p></div>
1041 <div class="paragraph"><p>Note: Make sure you quote the result when passing it to <tt>eval</tt>. See
1042 below for an example.</p></div>
1043 <h3 id="_input_format">Input Format</h3><div style="clear:left"></div>
1044 <div class="paragraph"><p><em>git rev-parse --parseopt</em> input format is fully text based. It has two parts,
1045 separated by a line that contains only <tt>--</tt>. The lines before the separator
1046 (should be more than one) are used for the usage.
1047 The lines after the separator describe the options.</p></div>
1048 <div class="paragraph"><p>Each line of options has this format:</p></div>
1049 <div class="listingblock">
1050 <div class="content">
1051 <pre><tt>&lt;opt_spec&gt;&lt;flags&gt;* SP+ help LF</tt></pre>
1052 </div></div>
1053 <div class="dlist"><dl>
1054 <dt class="hdlist1">
1055 <tt>&lt;opt_spec&gt;</tt>
1056 </dt>
1057 <dd>
1059 its format is the short option character, then the long option name
1060 separated by a comma. Both parts are not required, though at least one
1061 is necessary. <tt>h,help</tt>, <tt>dry-run</tt> and <tt>f</tt> are all three correct
1062 <tt>&lt;opt_spec&gt;</tt>.
1063 </p>
1064 </dd>
1065 <dt class="hdlist1">
1066 <tt>&lt;flags&gt;</tt>
1067 </dt>
1068 <dd>
1070 <tt>&lt;flags&gt;</tt> are of <tt>*</tt>, <tt>=</tt>, <tt>?</tt> or <tt>!</tt>.
1071 </p>
1072 <div class="ulist"><ul>
1073 <li>
1075 Use <tt>=</tt> if the option takes an argument.
1076 </p>
1077 </li>
1078 <li>
1080 Use <tt>?</tt> to mean that the option is optional (though its use is discouraged).
1081 </p>
1082 </li>
1083 <li>
1085 Use <tt>*</tt> to mean that this option should not be listed in the usage
1086 generated for the <tt>-h</tt> argument. It&#8217;s shown for <tt>--help-all</tt> as
1087 documented in <a href="gitcli.html">gitcli(7)</a>.
1088 </p>
1089 </li>
1090 <li>
1092 Use <tt>!</tt> to not make the corresponding negated long option available.
1093 </p>
1094 </li>
1095 </ul></div>
1096 </dd>
1097 </dl></div>
1098 <div class="paragraph"><p>The remainder of the line, after stripping the spaces, is used
1099 as the help associated to the option.</p></div>
1100 <div class="paragraph"><p>Blank lines are ignored, and lines that don&#8217;t match this specification are used
1101 as option group headers (start the line with a space to create such
1102 lines on purpose).</p></div>
1103 <h3 id="_example">Example</h3><div style="clear:left"></div>
1104 <div class="listingblock">
1105 <div class="content">
1106 <pre><tt>OPTS_SPEC="\
1107 some-command [options] &lt;args&gt;...
1109 some-command does foo and bar!
1111 h,help show the help
1113 foo some nifty option --foo
1114 bar= some cool option --bar with an argument
1116 An option group Header
1117 C? option C with an optional argument"
1119 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"</tt></pre>
1120 </div></div>
1121 </div>
1122 <h2 id="_sq_quote">SQ-QUOTE</h2>
1123 <div class="sectionbody">
1124 <div class="paragraph"><p>In <tt>--sq-quote</tt> mode, <em>git rev-parse</em> echoes on the standard output a
1125 single line suitable for <tt>sh(1)</tt> <tt>eval</tt>. This line is made by
1126 normalizing the arguments following <tt>--sq-quote</tt>. Nothing other than
1127 quoting the arguments is done.</p></div>
1128 <div class="paragraph"><p>If you want command input to still be interpreted as usual by
1129 <em>git rev-parse</em> before the output is shell quoted, see the <tt>--sq</tt>
1130 option.</p></div>
1131 <h3 id="_example_2">Example</h3><div style="clear:left"></div>
1132 <div class="listingblock">
1133 <div class="content">
1134 <pre><tt>$ cat &gt;your-git-script.sh &lt;&lt;\EOF
1135 #!/bin/sh
1136 args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments
1137 command="git frotz -n24 $args" # and use it inside a handcrafted
1138 # command line
1139 eval "$command"
1142 $ sh your-git-script.sh "a b'c"</tt></pre>
1143 </div></div>
1144 </div>
1145 <h2 id="_examples">EXAMPLES</h2>
1146 <div class="sectionbody">
1147 <div class="ulist"><ul>
1148 <li>
1150 Print the object name of the current commit:
1151 </p>
1152 <div class="listingblock">
1153 <div class="content">
1154 <pre><tt>$ git rev-parse --verify HEAD</tt></pre>
1155 </div></div>
1156 </li>
1157 <li>
1159 Print the commit object name from the revision in the $REV shell variable:
1160 </p>
1161 <div class="listingblock">
1162 <div class="content">
1163 <pre><tt>$ git rev-parse --verify $REV</tt></pre>
1164 </div></div>
1165 <div class="paragraph"><p>This will error out if $REV is empty or not a valid revision.</p></div>
1166 </li>
1167 <li>
1169 Same as above:
1170 </p>
1171 <div class="listingblock">
1172 <div class="content">
1173 <pre><tt>$ git rev-parse --default master --verify $REV</tt></pre>
1174 </div></div>
1175 <div class="paragraph"><p>but if $REV is empty, the commit object name from master will be printed.</p></div>
1176 </li>
1177 </ul></div>
1178 </div>
1179 <h2 id="_git">GIT</h2>
1180 <div class="sectionbody">
1181 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1182 </div>
1183 <div id="footer">
1184 <div id="footer-text">
1185 Last updated 2011-03-15 23:30:14 UTC
1186 </div>
1187 </div>
1188 </body>
1189 </html>