Autogenerated HTML docs for v1.7.5-185-g0b9dee
[git/jnareb-git.git] / git-rev-parse.html
blobd5355194917a115e14f83afd65e2d7b71b06ec5d
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 <em>&lt;rev&gt;</em> typically, but not necessarily, names a
757 commit object. It uses 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 name trees and
760 blobs contained in a commit.</p></div>
761 <div class="dlist"><dl>
762 <dt class="hdlist1">
763 <em>&lt;sha1&gt;</em>, e.g. <em>dae86e1950b1277e545cee180551750029cfe735</em>, <em>dae86e</em>
764 </dt>
765 <dd>
767 The full SHA1 object name (40-byte hexadecimal string), or
768 a leading substring that is unique within the repository.
769 E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both
770 name the same commit object if there is no other object in
771 your repository whose object name starts with dae86e.
772 </p>
773 </dd>
774 <dt class="hdlist1">
775 <em>&lt;describeOutput&gt;</em>, e.g. <em>v1.7.4.2-679-g3bee7fb</em>
776 </dt>
777 <dd>
779 Output from <tt>git describe</tt>; i.e. a closest tag, optionally
780 followed by a dash and a number of commits, followed by a dash, a
781 <em>g</em>, and an abbreviated object name.
782 </p>
783 </dd>
784 <dt class="hdlist1">
785 <em>&lt;refname&gt;</em>, e.g. <em>master</em>, <em>heads/master</em>, <em>refs/heads/master</em>
786 </dt>
787 <dd>
789 A symbolic ref name. E.g. <em>master</em> typically means the commit
790 object referenced by <em>refs/heads/master</em>. If you
791 happen to have both <em>heads/master</em> and <em>tags/master</em>, you can
792 explicitly say <em>heads/master</em> to tell git which one you mean.
793 When ambiguous, a <em>&lt;name&gt;</em> is disambiguated by taking the
794 first match in the following rules:
795 </p>
796 <div class="olist arabic"><ol class="arabic">
797 <li>
799 If <em>$GIT_DIR/&lt;name&gt;</em> exists, that is what you mean (this is usually
800 useful only for <em>HEAD</em>, <em>FETCH_HEAD</em>, <em>ORIG_HEAD</em>, <em>MERGE_HEAD</em>
801 and <em>CHERRY_PICK_HEAD</em>);
802 </p>
803 </li>
804 <li>
806 otherwise, <em>refs/&lt;name&gt;</em> if it exists;
807 </p>
808 </li>
809 <li>
811 otherwise, <em>refs/tags/&lt;refname&gt;</em> if it exists;
812 </p>
813 </li>
814 <li>
816 otherwise, <em>refs/heads/&lt;name&gt;</em> if it exists;
817 </p>
818 </li>
819 <li>
821 otherwise, <em>refs/remotes/&lt;name&gt;</em> if it exists;
822 </p>
823 </li>
824 <li>
826 otherwise, <em>refs/remotes/&lt;name&gt;/HEAD</em> if it exists.
827 </p>
828 <div class="paragraph"><p><em>HEAD</em> names the commit on which you based the changes in the working tree.
829 <em>FETCH_HEAD</em> records the branch which you fetched from a remote repository
830 with your last <tt>git fetch</tt> invocation.
831 <em>ORIG_HEAD</em> is created by commands that move your <em>HEAD</em> in a drastic
832 way, to record the position of the <em>HEAD</em> before their operation, so that
833 you can easily change the tip of the branch back to the state before you ran
834 them.
835 <em>MERGE_HEAD</em> records the commit(s) which you are merging into your branch
836 when you run <tt>git merge</tt>.
837 <em>CHERRY_PICK_HEAD</em> records the commit which you are cherry-picking
838 when you run <tt>git cherry-pick</tt>.</p></div>
839 <div class="paragraph"><p>Note that any of the <em>refs/*</em> cases above may come either from
840 the <em>$GIT_DIR/refs</em> directory or from the <em>$GIT_DIR/packed-refs</em> file.</p></div>
841 </li>
842 </ol></div>
843 </dd>
844 <dt class="hdlist1">
845 <em>&lt;refname&gt;@{&lt;date&gt;}</em>, e.g. <em>master@{yesterday}</em>, <em>HEAD@{5 minutes ago}</em>
846 </dt>
847 <dd>
849 A ref followed by the suffix <em>@</em> with a date specification
850 enclosed in a brace
851 pair (e.g. <em>{yesterday}</em>, <em>{1 month 2 weeks 3 days 1 hour 1
852 second ago}</em> or <em>{1979-02-26 18:30:00}</em>) specifies the value
853 of the ref at a prior point in time. This suffix may only be
854 used immediately following a ref name and the ref must have an
855 existing log (<em>$GIT_DIR/logs/&lt;ref&gt;</em>). Note that this looks up the state
856 of your <strong>local</strong> ref at a given time; e.g., what was in your local
857 <em>master</em> branch last week. If you want to look at commits made during
858 certain times, see <em>--since</em> and <em>--until</em>.
859 </p>
860 </dd>
861 <dt class="hdlist1">
862 <em>&lt;refname&gt;@{&lt;n&gt;}</em>, e.g. <em>master@{1}</em>
863 </dt>
864 <dd>
866 A ref followed by the suffix <em>@</em> with an ordinal specification
867 enclosed in a brace pair (e.g. <em>{1}</em>, <em>{15}</em>) specifies
868 the n-th prior value of that ref. For example <em>master@{1}</em>
869 is the immediate prior value of <em>master</em> while <em>master@{5}</em>
870 is the 5th prior value of <em>master</em>. This suffix may only be used
871 immediately following a ref name and the ref must have an existing
872 log (<em>$GIT_DIR/logs/&lt;refname&gt;</em>).
873 </p>
874 </dd>
875 <dt class="hdlist1">
876 <em>@{&lt;n&gt;}</em>, e.g. <em>@{1}</em>
877 </dt>
878 <dd>
880 You can use the <em>@</em> construct with an empty ref part to get at a
881 reflog entry of the current branch. For example, if you are on
882 branch <em>blabla</em> then <em>@{1}</em> means the same as <em>blabla@{1}</em>.
883 </p>
884 </dd>
885 <dt class="hdlist1">
886 <em>@{-&lt;n&gt;}</em>, e.g. <em>@{-1}</em>
887 </dt>
888 <dd>
890 The construct <em>@{-&lt;n&gt;}</em> means the &lt;n&gt;th branch checked out
891 before the current one.
892 </p>
893 </dd>
894 <dt class="hdlist1">
895 <em>&lt;refname&gt;@{upstream}</em>, e.g. <em>master@{upstream}</em>, <em>@{u}</em>
896 </dt>
897 <dd>
899 The suffix <em>@{upstream}</em> to a ref (short form <em>&lt;refname&gt;@{u}</em>) refers to
900 the branch the ref is set to build on top of. A missing ref defaults
901 to the current branch.
902 </p>
903 </dd>
904 <dt class="hdlist1">
905 <em>&lt;rev&gt;&#94;</em>, e.g. <em>HEAD&#94;, v1.5.1&#94;0</em>
906 </dt>
907 <dd>
909 A suffix <em>&#94;</em> to a revision parameter means the first parent of
910 that commit object. <em>&#94;&lt;n&gt;</em> means the &lt;n&gt;th parent (i.e.
911 <em>&lt;rev&gt;&#94;</em>
912 is equivalent to <em>&lt;rev&gt;&#94;1</em>). As a special rule,
913 <em>&lt;rev&gt;&#94;0</em> means the commit itself and is used when <em>&lt;rev&gt;</em> is the
914 object name of a tag object that refers to a commit object.
915 </p>
916 </dd>
917 <dt class="hdlist1">
918 <em>&lt;rev&gt;&#126;&lt;n&gt;</em>, e.g. <em>master&#126;3</em>
919 </dt>
920 <dd>
922 A suffix <em>&#126;&lt;n&gt;</em> to a revision parameter means the commit
923 object that is the &lt;n&gt;th generation grand-parent of the named
924 commit object, following only the first parents. I.e. <em>&lt;rev&gt;&#126;3</em> is
925 equivalent to <em>&lt;rev&gt;&#94;&#94;&#94;</em> which is equivalent to
926 <em>&lt;rev&gt;&#94;1&#94;1&#94;1</em>. See below for an illustration of
927 the usage of this form.
928 </p>
929 </dd>
930 <dt class="hdlist1">
931 <em>&lt;rev&gt;&#94;{&lt;type&gt;}</em>, e.g. <em>v0.99.8&#94;{commit}</em>
932 </dt>
933 <dd>
935 A suffix <em>&#94;</em> followed by an object type name enclosed in
936 brace pair means the object
937 could be a tag, and dereference the tag recursively until an
938 object of that type is found or the object cannot be
939 dereferenced anymore (in which case, barf). <em>&lt;rev&gt;&#94;0</em>
940 is a short-hand for <em>&lt;rev&gt;&#94;{commit}</em>.
941 </p>
942 </dd>
943 <dt class="hdlist1">
944 <em>&lt;rev&gt;&#94;{}</em>, e.g. <em>v0.99.8&#94;{}</em>
945 </dt>
946 <dd>
948 A suffix <em>&#94;</em> followed by an empty brace pair
949 means the object could be a tag,
950 and dereference the tag recursively until a non-tag object is
951 found.
952 </p>
953 </dd>
954 <dt class="hdlist1">
955 <em>&lt;rev&gt;&#94;{/&lt;text&gt;}</em>, e.g. <em>HEAD^{/fix nasty bug}</em>
956 </dt>
957 <dd>
959 A suffix <em>&#94;</em> to a revision parameter, followed by a brace
960 pair that contains a text led by a slash,
961 is the same as the <em>:/fix nasty bug</em> syntax below except that
962 it returns the youngest matching commit which is reachable from
963 the <em>&lt;rev&gt;</em> before <em>&#94;</em>.
964 </p>
965 </dd>
966 <dt class="hdlist1">
967 <em>:/&lt;text&gt;</em>, e.g. <em>:/fix nasty bug</em>
968 </dt>
969 <dd>
971 A colon, followed by a slash, followed by a text, names
972 a commit whose commit message matches the specified regular expression.
973 This name returns the youngest matching commit which is
974 reachable from any ref. If the commit message starts with a
975 <em>!</em> you have to repeat that; the special sequence <em>:/!</em>,
976 followed by something else than <em>!</em>, is reserved for now.
977 The regular expression can match any part of the commit message. To
978 match messages starting with a string, one can use e.g. <em>:/^foo</em>.
979 </p>
980 </dd>
981 <dt class="hdlist1">
982 <em>&lt;rev&gt;:&lt;path&gt;</em>, e.g. <em>HEAD:README</em>, <em>:README</em>, <em>master:./README</em>
983 </dt>
984 <dd>
986 A suffix <em>:</em> followed by a path names the blob or tree
987 at the given path in the tree-ish object named by the part
988 before the colon.
989 <em>:path</em> (with an empty part before the colon)
990 is a special case of the syntax described next: content
991 recorded in the index at the given path.
992 A path starting with <em>./</em> or <em>../</em> is relative to the current working directory.
993 The given path will be converted to be relative to the working tree&#8217;s root directory.
994 This is most useful to address a blob or tree from a commit or tree that has
995 the same tree structure as the working tree.
996 </p>
997 </dd>
998 <dt class="hdlist1">
999 <em>:&lt;n&gt;:&lt;path&gt;</em>, e.g. <em>:0:README</em>, <em>:README</em>
1000 </dt>
1001 <dd>
1003 A colon, optionally followed by a stage number (0 to 3) and a
1004 colon, followed by a path, names a blob object in the
1005 index at the given path. A missing stage number (and the colon
1006 that follows it) names a stage 0 entry. During a merge, stage
1007 1 is the common ancestor, stage 2 is the target branch&#8217;s version
1008 (typically the current branch), and stage 3 is the version from
1009 the branch which is being merged.
1010 </p>
1011 </dd>
1012 </dl></div>
1013 <div class="paragraph"><p>Here is an illustration, by Jon Loeliger. Both commit nodes B
1014 and C are parents of commit node A. Parent commits are ordered
1015 left-to-right.</p></div>
1016 <div class="literalblock">
1017 <div class="content">
1018 <pre><tt>G H I J
1019 \ / \ /
1020 D E F
1021 \ | / \
1022 \ | / |
1023 \|/ |
1027 A</tt></pre>
1028 </div></div>
1029 <div class="literalblock">
1030 <div class="content">
1031 <pre><tt>A = = A^0
1032 B = A^ = A^1 = A~1
1033 C = A^2 = A^2
1034 D = A^^ = A^1^1 = A~2
1035 E = B^2 = A^^2
1036 F = B^3 = A^^3
1037 G = A^^^ = A^1^1^1 = A~3
1038 H = D^2 = B^^2 = A^^^2 = A~2^2
1039 I = F^ = B^3^ = A^^3^
1040 J = F^2 = B^3^2 = A^^3^2</tt></pre>
1041 </div></div>
1042 </div>
1043 <h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
1044 <div class="sectionbody">
1045 <div class="paragraph"><p>History traversing commands such as <tt>git log</tt> operate on a set
1046 of commits, not just a single commit. To these commands,
1047 specifying a single revision with the notation described in the
1048 previous section means the set of commits reachable from that
1049 commit, following the commit ancestry chain.</p></div>
1050 <div class="paragraph"><p>To exclude commits reachable from a commit, a prefix <em>&#94;</em>
1051 notation is used. E.g. <em>&#94;r1 r2</em> means commits reachable
1052 from <em>r2</em> but exclude the ones reachable from <em>r1</em>.</p></div>
1053 <div class="paragraph"><p>This set operation appears so often that there is a shorthand
1054 for it. When you have two commits <em>r1</em> and <em>r2</em> (named according
1055 to the syntax explained in SPECIFYING REVISIONS above), you can ask
1056 for commits that are reachable from r2 excluding those that are reachable
1057 from r1 by <em>&#94;r1 r2</em> and it can be written as <em>r1..r2</em>.</p></div>
1058 <div class="paragraph"><p>A similar notation <em>r1...r2</em> is called symmetric difference
1059 of <em>r1</em> and <em>r2</em> and is defined as
1060 <em>r1 r2 --not $(git merge-base --all r1 r2)</em>.
1061 It is the set of commits that are reachable from either one of
1062 <em>r1</em> or <em>r2</em> but not from both.</p></div>
1063 <div class="paragraph"><p>Two other shorthands for naming a set that is formed by a commit
1064 and its parent commits exist. The <em>r1&#94;@</em> notation means all
1065 parents of <em>r1</em>. <em>r1&#94;!</em> includes commit <em>r1</em> but excludes
1066 all of its parents.</p></div>
1067 <div class="paragraph"><p>Here are a handful of examples:</p></div>
1068 <div class="literalblock">
1069 <div class="content">
1070 <pre><tt>D G H D
1071 D F G H I J D F
1072 ^G D H D
1073 ^D B E I J F B
1074 B...C G H D E B C
1075 ^D B C E I J F B C
1076 C^@ I J F
1077 F^! D G H D F</tt></pre>
1078 </div></div>
1079 </div>
1080 <h2 id="_parseopt">PARSEOPT</h2>
1081 <div class="sectionbody">
1082 <div class="paragraph"><p>In <tt>--parseopt</tt> mode, <em>git rev-parse</em> helps massaging options to bring to shell
1083 scripts the same facilities C builtins have. It works as an option normalizer
1084 (e.g. splits single switches aggregate values), a bit like <tt>getopt(1)</tt> does.</p></div>
1085 <div class="paragraph"><p>It takes on the standard input the specification of the options to parse and
1086 understand, and echoes on the standard output a string suitable for <tt>sh(1)</tt> <tt>eval</tt>
1087 to replace the arguments with normalized ones. In case of error, it outputs
1088 usage on the standard error stream, and exits with code 129.</p></div>
1089 <div class="paragraph"><p>Note: Make sure you quote the result when passing it to <tt>eval</tt>. See
1090 below for an example.</p></div>
1091 <h3 id="_input_format">Input Format</h3><div style="clear:left"></div>
1092 <div class="paragraph"><p><em>git rev-parse --parseopt</em> input format is fully text based. It has two parts,
1093 separated by a line that contains only <tt>--</tt>. The lines before the separator
1094 (should be more than one) are used for the usage.
1095 The lines after the separator describe the options.</p></div>
1096 <div class="paragraph"><p>Each line of options has this format:</p></div>
1097 <div class="listingblock">
1098 <div class="content">
1099 <pre><tt>&lt;opt_spec&gt;&lt;flags&gt;* SP+ help LF</tt></pre>
1100 </div></div>
1101 <div class="dlist"><dl>
1102 <dt class="hdlist1">
1103 <tt>&lt;opt_spec&gt;</tt>
1104 </dt>
1105 <dd>
1107 its format is the short option character, then the long option name
1108 separated by a comma. Both parts are not required, though at least one
1109 is necessary. <tt>h,help</tt>, <tt>dry-run</tt> and <tt>f</tt> are all three correct
1110 <tt>&lt;opt_spec&gt;</tt>.
1111 </p>
1112 </dd>
1113 <dt class="hdlist1">
1114 <tt>&lt;flags&gt;</tt>
1115 </dt>
1116 <dd>
1118 <tt>&lt;flags&gt;</tt> are of <tt>*</tt>, <tt>=</tt>, <tt>?</tt> or <tt>!</tt>.
1119 </p>
1120 <div class="ulist"><ul>
1121 <li>
1123 Use <tt>=</tt> if the option takes an argument.
1124 </p>
1125 </li>
1126 <li>
1128 Use <tt>?</tt> to mean that the option is optional (though its use is discouraged).
1129 </p>
1130 </li>
1131 <li>
1133 Use <tt>*</tt> to mean that this option should not be listed in the usage
1134 generated for the <tt>-h</tt> argument. It&#8217;s shown for <tt>--help-all</tt> as
1135 documented in <a href="gitcli.html">gitcli(7)</a>.
1136 </p>
1137 </li>
1138 <li>
1140 Use <tt>!</tt> to not make the corresponding negated long option available.
1141 </p>
1142 </li>
1143 </ul></div>
1144 </dd>
1145 </dl></div>
1146 <div class="paragraph"><p>The remainder of the line, after stripping the spaces, is used
1147 as the help associated to the option.</p></div>
1148 <div class="paragraph"><p>Blank lines are ignored, and lines that don&#8217;t match this specification are used
1149 as option group headers (start the line with a space to create such
1150 lines on purpose).</p></div>
1151 <h3 id="_example">Example</h3><div style="clear:left"></div>
1152 <div class="listingblock">
1153 <div class="content">
1154 <pre><tt>OPTS_SPEC="\
1155 some-command [options] &lt;args&gt;...
1157 some-command does foo and bar!
1159 h,help show the help
1161 foo some nifty option --foo
1162 bar= some cool option --bar with an argument
1164 An option group Header
1165 C? option C with an optional argument"
1167 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"</tt></pre>
1168 </div></div>
1169 </div>
1170 <h2 id="_sq_quote">SQ-QUOTE</h2>
1171 <div class="sectionbody">
1172 <div class="paragraph"><p>In <tt>--sq-quote</tt> mode, <em>git rev-parse</em> echoes on the standard output a
1173 single line suitable for <tt>sh(1)</tt> <tt>eval</tt>. This line is made by
1174 normalizing the arguments following <tt>--sq-quote</tt>. Nothing other than
1175 quoting the arguments is done.</p></div>
1176 <div class="paragraph"><p>If you want command input to still be interpreted as usual by
1177 <em>git rev-parse</em> before the output is shell quoted, see the <tt>--sq</tt>
1178 option.</p></div>
1179 <h3 id="_example_2">Example</h3><div style="clear:left"></div>
1180 <div class="listingblock">
1181 <div class="content">
1182 <pre><tt>$ cat &gt;your-git-script.sh &lt;&lt;\EOF
1183 #!/bin/sh
1184 args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments
1185 command="git frotz -n24 $args" # and use it inside a handcrafted
1186 # command line
1187 eval "$command"
1190 $ sh your-git-script.sh "a b'c"</tt></pre>
1191 </div></div>
1192 </div>
1193 <h2 id="_examples">EXAMPLES</h2>
1194 <div class="sectionbody">
1195 <div class="ulist"><ul>
1196 <li>
1198 Print the object name of the current commit:
1199 </p>
1200 <div class="listingblock">
1201 <div class="content">
1202 <pre><tt>$ git rev-parse --verify HEAD</tt></pre>
1203 </div></div>
1204 </li>
1205 <li>
1207 Print the commit object name from the revision in the $REV shell variable:
1208 </p>
1209 <div class="listingblock">
1210 <div class="content">
1211 <pre><tt>$ git rev-parse --verify $REV</tt></pre>
1212 </div></div>
1213 <div class="paragraph"><p>This will error out if $REV is empty or not a valid revision.</p></div>
1214 </li>
1215 <li>
1217 Same as above:
1218 </p>
1219 <div class="listingblock">
1220 <div class="content">
1221 <pre><tt>$ git rev-parse --default master --verify $REV</tt></pre>
1222 </div></div>
1223 <div class="paragraph"><p>but if $REV is empty, the commit object name from master will be printed.</p></div>
1224 </li>
1225 </ul></div>
1226 </div>
1227 <h2 id="_git">GIT</h2>
1228 <div class="sectionbody">
1229 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1230 </div>
1231 <div id="footer">
1232 <div id="footer-text">
1233 Last updated 2011-03-15 23:30:14 UTC
1234 </div>
1235 </div>
1236 </body>
1237 </html>