1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"application/xhtml+xml; charset=UTF-8" />
7 <meta name=
"generator" content=
"AsciiDoc 10.2.0" />
8 <title>git-show(
1)
</title>
9 <style type=
"text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType ==
1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute(
"class") || i.getAttribute(
"className")) !=
"float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[
1]-
1);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-note");
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[
1];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
694 // Process footnoterefs.
695 for (i=
0; i
<spans.length; i++) {
696 if (spans[i].className ==
"footnoteref") {
697 var href = spans[i].getElementsByTagName(
"a")[
0].getAttribute(
"href");
698 href = href.match(/#.*/)[
0]; // Because IE return full URL.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-show(
1) Manual Page
741 <div class=
"sectionbody">
743 Show various types of objects
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git show
</em> [
<options
>] [
<object
>…]
</pre>
753 <div class=
"attribution">
758 <h2 id=
"_description">DESCRIPTION
</h2>
759 <div class=
"sectionbody">
760 <div class=
"paragraph"><p>Shows one or more objects (blobs, trees, tags and commits).
</p></div>
761 <div class=
"paragraph"><p>For commits it shows the log message and textual diff. It also
762 presents the merge commit in a special format as produced by
763 <em>git diff-tree --cc
</em>.
</p></div>
764 <div class=
"paragraph"><p>For tags, it shows the tag message and the referenced objects.
</p></div>
765 <div class=
"paragraph"><p>For trees, it shows the names (equivalent to
<em>git ls-tree
</em>
766 with --name-only).
</p></div>
767 <div class=
"paragraph"><p>For plain blobs, it shows the plain contents.
</p></div>
768 <div class=
"paragraph"><p>Some options that
<em>git log
</em> command understands can be used to
769 control how the changes the commit introduces are shown.
</p></div>
770 <div class=
"paragraph"><p>This manual page describes only the most frequently used options.
</p></div>
774 <h2 id=
"_options">OPTIONS
</h2>
775 <div class=
"sectionbody">
776 <div class=
"dlist"><dl>
778 <object
>…
782 The names of objects to show (defaults to
<em>HEAD
</em>).
783 For a more complete list of ways to spell object names, see
784 "SPECIFYING REVISIONS" section in
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>.
788 --pretty[=
<format
>]
791 --format=
<format
>
795 Pretty-print the contents of the commit logs in a given format,
796 where
<em><format
></em> can be one of
<em>oneline
</em>,
<em>short
</em>,
<em>medium
</em>,
797 <em>full
</em>,
<em>fuller
</em>,
<em>reference
</em>,
<em>email
</em>,
<em>raw
</em>,
<em>format:
<string
></em>
798 and
<em>tformat:
<string
></em>. When
<em><format
></em> is none of the above,
799 and has
<em>%placeholder
</em> in it, it acts as if
800 <em>--pretty=tformat:
<format
></em> were given.
802 <div class=
"paragraph"><p>See the
"PRETTY FORMATS" section for some additional details for each
803 format. When
<em>=
<format
></em> part is omitted, it defaults to
<em>medium
</em>.
</p></div>
804 <div class=
"paragraph"><p>Note: you can specify the default pretty format in the repository
805 configuration (see
<a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
812 Instead of showing the full
40-byte hexadecimal commit object
813 name, show a prefix that names the object uniquely.
814 "--abbrev=<n>" (which also modifies diff output, if it is displayed)
815 option can be used to specify the minimum length of the prefix.
817 <div class=
"paragraph"><p>This should make
"--pretty=oneline" a whole lot more readable for
818 people using
80-column terminals.
</p></div>
825 Show the full
40-byte hexadecimal commit object name. This negates
826 <code>--abbrev-commit
</code>, either explicit or implied by other options such
827 as
"--oneline". It also overrides the
<code>log.abbrevCommit
</code> variable.
835 This is a shorthand for
"--pretty=oneline --abbrev-commit"
840 --encoding=
<encoding
>
844 Commit objects record the character encoding used for the log message
845 in their encoding header; this option can be used to tell the
846 command to re-code the commit log message in the encoding
847 preferred by the user. For non plumbing commands this
848 defaults to UTF-
8. Note that if an object claims to be encoded
849 in
<code>X
</code> and we are outputting in
<code>X
</code>, we will output the object
850 verbatim; this means that invalid sequences in the original
851 commit may be copied to the output. Likewise, if iconv(
3) fails
852 to convert the commit, we will quietly output the original
857 --expand-tabs=
<n
>
867 Perform a tab expansion (replace each tab with enough spaces
868 to fill to the next display column that is a multiple of
<em><n
></em>)
869 in the log message before showing it in the output.
870 <code>--expand-tabs
</code> is a short-hand for
<code>--expand-tabs=
8</code>, and
871 <code>--no-expand-tabs
</code> is a short-hand for
<code>--expand-tabs=
0</code>,
872 which disables tab expansion.
874 <div class=
"paragraph"><p>By default, tabs are expanded in pretty formats that indent the log
875 message by
4 spaces (i.e.
<em>medium
</em>, which is the default,
<em>full
</em>,
876 and
<em>fuller
</em>).
</p></div>
879 --notes[=
<ref
>]
883 Show the notes (see
<a href=
"git-notes.html">git-notes(
1)
</a>) that annotate the
884 commit, when showing the commit log message. This is the default
885 for
<code>git log
</code>,
<code>git show
</code> and
<code>git whatchanged
</code> commands when
886 there is no
<code>--pretty
</code>,
<code>--format
</code>, or
<code>--oneline
</code> option given
889 <div class=
"paragraph"><p>By default, the notes shown are from the notes refs listed in the
890 <code>core.notesRef
</code> and
<code>notes.displayRef
</code> variables (or corresponding
891 environment overrides). See
<a href=
"git-config.html">git-config(
1)
</a> for more details.
</p></div>
892 <div class=
"paragraph"><p>With an optional
<em><ref
></em> argument, use the ref to find the notes
893 to display. The ref can specify the full refname when it begins
894 with
<code>refs/notes/
</code>; when it begins with
<code>notes/
</code>,
<code>refs/
</code> and otherwise
895 <code>refs/notes/
</code> is prefixed to form the full name of the ref.
</p></div>
896 <div class=
"paragraph"><p>Multiple --notes options can be combined to control which notes are
897 being displayed. Examples:
"--notes=foo" will show only notes from
898 "refs/notes/foo";
"--notes=foo --notes" will show both notes from
899 "refs/notes/foo" and from the default notes ref(s).
</p></div>
906 Do not show notes. This negates the above
<code>--notes
</code> option, by
907 resetting the list of notes refs from which notes are shown.
908 Options are parsed in the order given on the command line, so e.g.
909 "--notes --notes=foo --no-notes --notes=bar" will only show notes
910 from
"refs/notes/bar".
914 --show-notes-by-default
918 Show the default notes unless options for displaying specific
923 --show-notes[=
<ref
>]
926 --[no-]standard-notes
930 These options are deprecated. Use the above --notes/--no-notes
939 Check the validity of a signed commit object by passing the signature
940 to
<code>gpg --verify
</code> and show the output.
947 <h2 id=
"_pretty_formats">PRETTY FORMATS
</h2>
948 <div class=
"sectionbody">
949 <div class=
"paragraph"><p>If the commit is a merge, and if the pretty-format
950 is not
<em>oneline
</em>,
<em>email
</em> or
<em>raw
</em>, an additional line is
951 inserted before the
<em>Author:
</em> line. This line begins with
952 "Merge: " and the hashes of ancestral commits are printed,
953 separated by spaces. Note that the listed commits may not
954 necessarily be the list of the
<strong>direct
</strong> parent commits if you
955 have limited your view of history: for example, if you are
956 only interested in changes related to a certain directory or
958 <div class=
"paragraph"><p>There are several built-in formats, and you can define
959 additional formats by setting a pretty.
<name
>
960 config option to either another format name, or a
961 <em>format:
</em> string, as described below (see
962 <a href=
"git-config.html">git-config(
1)
</a>). Here are the details of the
963 built-in formats:
</p></div>
964 <div class=
"ulist"><ul>
969 <div class=
"literalblock">
970 <div class=
"content">
971 <pre><code><hash
> <title-line
></code></pre>
973 <div class=
"paragraph"><p>This is designed to be as compact as possible.
</p></div>
979 <div class=
"literalblock">
980 <div class=
"content">
981 <pre><code>commit
<hash
>
982 Author:
<author
></code></pre>
984 <div class=
"literalblock">
985 <div class=
"content">
986 <pre><code><title-line
></code></pre>
993 <div class=
"literalblock">
994 <div class=
"content">
995 <pre><code>commit
<hash
>
996 Author:
<author
>
997 Date:
<author-date
></code></pre>
999 <div class=
"literalblock">
1000 <div class=
"content">
1001 <pre><code><title-line
></code></pre>
1003 <div class=
"literalblock">
1004 <div class=
"content">
1005 <pre><code><full-commit-message
></code></pre>
1012 <div class=
"literalblock">
1013 <div class=
"content">
1014 <pre><code>commit
<hash
>
1015 Author:
<author
>
1016 Commit:
<committer
></code></pre>
1018 <div class=
"literalblock">
1019 <div class=
"content">
1020 <pre><code><title-line
></code></pre>
1022 <div class=
"literalblock">
1023 <div class=
"content">
1024 <pre><code><full-commit-message
></code></pre>
1031 <div class=
"literalblock">
1032 <div class=
"content">
1033 <pre><code>commit
<hash
>
1034 Author:
<author
>
1035 AuthorDate:
<author-date
>
1036 Commit:
<committer
>
1037 CommitDate:
<committer-date
></code></pre>
1039 <div class=
"literalblock">
1040 <div class=
"content">
1041 <pre><code><title-line
></code></pre>
1043 <div class=
"literalblock">
1044 <div class=
"content">
1045 <pre><code><full-commit-message
></code></pre>
1052 <div class=
"literalblock">
1053 <div class=
"content">
1054 <pre><code><abbrev-hash
> (
<title-line
>,
<short-author-date
>)
</code></pre>
1056 <div class=
"paragraph"><p>This format is used to refer to another commit in a commit message and
1057 is the same as
<code>--pretty='format:%C(auto)%h (%s, %ad)'
</code>. By default,
1058 the date is formatted with
<code>--date=short
</code> unless another
<code>--date
</code> option
1059 is explicitly specified. As with any
<code>format:
</code> with format
1060 placeholders, its output is not affected by other options like
1061 <code>--decorate
</code> and
<code>--walk-reflogs
</code>.
</p></div>
1067 <div class=
"literalblock">
1068 <div class=
"content">
1069 <pre><code>From
<hash
> <date
>
1070 From:
<author
>
1071 Date:
<author-date
>
1072 Subject: [PATCH]
<title-line
></code></pre>
1074 <div class=
"literalblock">
1075 <div class=
"content">
1076 <pre><code><full-commit-message
></code></pre>
1083 <div class=
"paragraph"><p>Like
<em>email
</em>, but lines in the commit message starting with
"From "
1084 (preceded by zero or more
">") are quoted with
">" so they aren
’t
1085 confused as starting a new commit.
</p></div>
1091 <div class=
"paragraph"><p>The
<em>raw
</em> format shows the entire commit exactly as
1092 stored in the commit object. Notably, the hashes are
1093 displayed in full, regardless of whether --abbrev or
1094 --no-abbrev are used, and
<em>parents
</em> information show the
1095 true parent commits, without taking grafts or history
1096 simplification into account. Note that this format affects the way
1097 commits are displayed, but not the way the diff is shown e.g. with
1098 <code>git log --raw
</code>. To get full object names in a raw diff format,
1099 use
<code>--no-abbrev
</code>.
</p></div>
1103 <em>format:
<format-string
></em>
1105 <div class=
"paragraph"><p>The
<em>format:
<format-string
></em> format allows you to specify which information
1106 you want to show. It works a little bit like printf format,
1107 with the notable exception that you get a newline with
<em>%n
</em>
1108 instead of
<em>\n
</em>.
</p></div>
1109 <div class=
"paragraph"><p>E.g,
<em>format:
"The author of %h was %an, %ar%nThe title was >>%s<<%n"</em>
1110 would show something like this:
</p></div>
1111 <div class=
"listingblock">
1112 <div class=
"content">
1113 <pre><code>The author of fe6e0ee was Junio C Hamano,
23 hours ago
1114 The title was
>>t4119: test autocomputing -p
<n
> for traditional diff input.
<<</code></pre>
1116 <div class=
"paragraph"><p>The placeholders are:
</p></div>
1117 <div class=
"ulist"><ul>
1120 Placeholders that expand to a single literal character:
1122 <div class=
"dlist"><dl>
1123 <dt class=
"hdlist1">
1131 <dt class=
"hdlist1">
1139 <dt class=
"hdlist1">
1144 <em>%x
</em> followed by two hexadecimal digits is replaced with a
1145 byte with the hexadecimal digits' value (we will call this
1146 "literal formatting code" in the rest of this document).
1153 Placeholders that affect formatting of later placeholders:
1155 <div class=
"dlist"><dl>
1156 <dt class=
"hdlist1">
1164 <dt class=
"hdlist1">
1169 switch color to green
1172 <dt class=
"hdlist1">
1177 switch color to blue
1180 <dt class=
"hdlist1">
1188 <dt class=
"hdlist1">
1189 <em>%C(
…)
</em>
1193 color specification, as described under Values in the
1194 "CONFIGURATION FILE" section of
<a href=
"git-config.html">git-config(
1)
</a>. By
1195 default, colors are shown only when enabled for log output
1196 (by
<code>color.diff
</code>,
<code>color.ui
</code>, or
<code>--color
</code>, and respecting
1197 the
<code>auto
</code> settings of the former if we are going to a
1198 terminal).
<code>%C(auto,...)
</code> is accepted as a historical
1199 synonym for the default (e.g.,
<code>%C(auto,red)
</code>). Specifying
1200 <code>%C(always,...)
</code> will show the colors even when color is
1201 not otherwise enabled (though consider just using
1202 <code>--color=always
</code> to enable color for the whole output,
1203 including this format and anything else git might color).
1204 <code>auto
</code> alone (i.e.
<code>%C(auto)
</code>) will turn on auto coloring
1205 on the next placeholders until the color is switched
1209 <dt class=
"hdlist1">
1214 left (
<code><</code>), right (
<code>></code>) or boundary (
<code>-
</code>) mark
1217 <dt class=
"hdlist1">
1218 <em>%w([
<w
>[,
<i1
>[,
<i2
>]]])
</em>
1222 switch line wrapping, like the -w option of
1223 <a href=
"git-shortlog.html">git-shortlog(
1)
</a>.
1226 <dt class=
"hdlist1">
1227 <em>%
<(
<N
> [,trunc|ltrunc|mtrunc])
</em>
1231 make the next placeholder take at
1232 least N column widths, padding spaces on
1233 the right if necessary. Optionally
1234 truncate (with ellipsis
<em>..
</em>) at the left (ltrunc)
<code>..ft
</code>,
1235 the middle (mtrunc)
<code>mi..le
</code>, or the end
1236 (trunc)
<code>rig..
</code>, if the output is longer than
1238 Note
1: that truncating
1239 only works correctly with N
>=
2.
1240 Note
2: spaces around the N and M (see below)
1241 values are optional.
1242 Note
3: Emojis and other wide characters
1243 will take two display columns, which may
1244 over-run column boundaries.
1245 Note
4: decomposed character combining marks
1246 may be misplaced at padding boundaries.
1249 <dt class=
"hdlist1">
1250 <em>%
<|(
<M
> )
</em>
1254 make the next placeholder take at least until Mth
1255 display column, padding spaces on the right if necessary.
1256 Use negative M values for column positions measured
1257 from the right hand edge of the terminal window.
1260 <dt class=
"hdlist1">
1261 <em>%
>(
<N
> )
</em>,
<em>%
>|(
<M
> )
</em>
1265 similar to
<em>%
<(
<N
> )
</em>,
<em>%
<|(
<M
> )
</em> respectively,
1266 but padding spaces on the left
1269 <dt class=
"hdlist1">
1270 <em>%
>>(
<N
> )
</em>,
<em>%
>>|(
<M
> )
</em>
1274 similar to
<em>%
>(
<N
> )
</em>,
<em>%
>|(
<M
> )
</em>
1275 respectively, except that if the next
1276 placeholder takes more spaces than given and
1277 there are spaces on its left, use those
1281 <dt class=
"hdlist1">
1282 <em>%
><(
<N
> )
</em>,
<em>%
><|(
<M
> )
</em>
1286 similar to
<em>%
<(
<N
> )
</em>,
<em>%
<|(
<M
> )
</em>
1287 respectively, but padding both sides
1288 (i.e. the text is centered)
1295 Placeholders that expand to information extracted from the commit:
1297 <div class=
"dlist"><dl>
1298 <dt class=
"hdlist1">
1306 <dt class=
"hdlist1">
1311 abbreviated commit hash
1314 <dt class=
"hdlist1">
1322 <dt class=
"hdlist1">
1327 abbreviated tree hash
1330 <dt class=
"hdlist1">
1338 <dt class=
"hdlist1">
1343 abbreviated parent hashes
1346 <dt class=
"hdlist1">
1354 <dt class=
"hdlist1">
1359 author name (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a>
1360 or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1363 <dt class=
"hdlist1">
1371 <dt class=
"hdlist1">
1376 author email (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a>
1377 or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1380 <dt class=
"hdlist1">
1385 author email local-part (the part before the
<em>@
</em> sign)
1388 <dt class=
"hdlist1">
1393 author local-part (see
<em>%al
</em>) respecting .mailmap, see
1394 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1397 <dt class=
"hdlist1">
1402 author date (format respects --date= option)
1405 <dt class=
"hdlist1">
1410 author date, RFC2822 style
1413 <dt class=
"hdlist1">
1418 author date, relative
1421 <dt class=
"hdlist1">
1426 author date, UNIX timestamp
1429 <dt class=
"hdlist1">
1434 author date, ISO
8601-like format
1437 <dt class=
"hdlist1">
1442 author date, strict ISO
8601 format
1445 <dt class=
"hdlist1">
1450 author date, short format (
<code>YYYY-MM-DD
</code>)
1453 <dt class=
"hdlist1">
1458 author date, human style (like the
<code>--date=human
</code> option of
1459 <a href=
"git-rev-list.html">git-rev-list(
1)
</a>)
1462 <dt class=
"hdlist1">
1470 <dt class=
"hdlist1">
1475 committer name (respecting .mailmap, see
1476 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1479 <dt class=
"hdlist1">
1487 <dt class=
"hdlist1">
1492 committer email (respecting .mailmap, see
1493 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1496 <dt class=
"hdlist1">
1501 committer email local-part (the part before the
<em>@
</em> sign)
1504 <dt class=
"hdlist1">
1509 committer local-part (see
<em>%cl
</em>) respecting .mailmap, see
1510 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1513 <dt class=
"hdlist1">
1518 committer date (format respects --date= option)
1521 <dt class=
"hdlist1">
1526 committer date, RFC2822 style
1529 <dt class=
"hdlist1">
1534 committer date, relative
1537 <dt class=
"hdlist1">
1542 committer date, UNIX timestamp
1545 <dt class=
"hdlist1">
1550 committer date, ISO
8601-like format
1553 <dt class=
"hdlist1">
1558 committer date, strict ISO
8601 format
1561 <dt class=
"hdlist1">
1566 committer date, short format (
<code>YYYY-MM-DD
</code>)
1569 <dt class=
"hdlist1">
1574 committer date, human style (like the
<code>--date=human
</code> option of
1575 <a href=
"git-rev-list.html">git-rev-list(
1)
</a>)
1578 <dt class=
"hdlist1">
1583 ref names, like the --decorate option of
<a href=
"git-log.html">git-log(
1)
</a>
1586 <dt class=
"hdlist1">
1591 ref names without the
" (",
")" wrapping.
1594 <dt class=
"hdlist1">
1595 <em>%(decorate[:
<options
>])
</em>
1599 ref names with custom decorations. The
<code>decorate
</code> string may be followed by a
1600 colon and zero or more comma-separated options. Option values may contain
1601 literal formatting codes. These must be used for commas (
<code>%x2C
</code>) and closing
1602 parentheses (
<code>%x29
</code>), due to their role in the option syntax.
1604 <div class=
"ulist"><ul>
1607 <em>prefix=
<value
></em>: Shown before the list of ref names. Defaults to
" <code>(</code>".
1612 <em>suffix=
<value
></em>: Shown after the list of ref names. Defaults to
"<code>)</code>".
1617 <em>separator=
<value
></em>: Shown between ref names. Defaults to
"<code>,</code> ".
1622 <em>pointer=
<value
></em>: Shown between HEAD and the branch it points to, if any.
1623 Defaults to
" <code>-></code> ".
1628 <em>tag=
<value
></em>: Shown before tag names. Defaults to
"<code>tag:</code> ".
1632 <div class=
"paragraph"><p>For example, to produce decorations with no wrapping
1633 or tag annotations, and spaces as separators:
</p></div>
1634 <div class=
"paragraph"><p><code>%(decorate:prefix=,suffix=,tag=,separator= )
</code></p></div>
1636 <dt class=
"hdlist1">
1637 <em>%(describe[:
<options
>])
</em>
1641 human-readable name, like
<a href=
"git-describe.html">git-describe(
1)
</a>; empty string for
1642 undescribable commits. The
<code>describe
</code> string may be followed by a colon and
1643 zero or more comma-separated options. Descriptions can be inconsistent when
1644 tags are added or removed at the same time.
1646 <div class=
"ulist"><ul>
1649 <em>tags[=
<bool-value
>]
</em>: Instead of only considering annotated tags,
1650 consider lightweight tags as well.
1655 <em>abbrev=
<number
></em>: Instead of using the default number of hexadecimal digits
1656 (which will vary according to the number of objects in the repository with a
1657 default of
7) of the abbreviated object name, use
<number
> digits, or as many
1658 digits as needed to form a unique object name.
1663 <em>match=
<pattern
></em>: Only consider tags matching the given
1664 <code>glob(
7)
</code> pattern, excluding the
"refs/tags/" prefix.
1669 <em>exclude=
<pattern
></em>: Do not consider tags matching the given
1670 <code>glob(
7)
</code> pattern, excluding the
"refs/tags/" prefix.
1675 <dt class=
"hdlist1">
1680 ref name given on the command line by which the commit was reached
1681 (like
<code>git log --source
</code>), only works with
<code>git log
</code>
1684 <dt class=
"hdlist1">
1692 <dt class=
"hdlist1">
1700 <dt class=
"hdlist1">
1705 sanitized subject line, suitable for a filename
1708 <dt class=
"hdlist1">
1716 <dt class=
"hdlist1">
1721 raw body (unwrapped subject and body)
1724 <dt class=
"hdlist1">
1732 <dt class=
"hdlist1">
1737 raw verification message from GPG for a signed commit
1740 <dt class=
"hdlist1">
1745 show
"G" for a good (valid) signature,
1746 "B" for a bad signature,
1747 "U" for a good signature with unknown validity,
1748 "X" for a good signature that has expired,
1749 "Y" for a good signature made by an expired key,
1750 "R" for a good signature made by a revoked key,
1751 "E" if the signature cannot be checked (e.g. missing key)
1752 and
"N" for no signature
1755 <dt class=
"hdlist1">
1760 show the name of the signer for a signed commit
1763 <dt class=
"hdlist1">
1768 show the key used to sign a signed commit
1771 <dt class=
"hdlist1">
1776 show the fingerprint of the key used to sign a signed commit
1779 <dt class=
"hdlist1">
1784 show the fingerprint of the primary key whose subkey was used
1785 to sign a signed commit
1788 <dt class=
"hdlist1">
1793 show the trust level for the key used to sign a signed commit
1796 <dt class=
"hdlist1">
1801 reflog selector, e.g.,
<code>refs/stash@{
1}
</code> or
<code>refs/stash@{
2
1802 minutes ago}
</code>; the format follows the rules described for the
1803 <code>-g
</code> option. The portion before the
<code>@
</code> is the refname as
1804 given on the command line (so
<code>git log -g refs/heads/master
</code>
1805 would yield
<code>refs/heads/master@{
0}
</code>).
1808 <dt class=
"hdlist1">
1813 shortened reflog selector; same as
<code>%gD
</code>, but the refname
1814 portion is shortened for human readability (so
1815 <code>refs/heads/master
</code> becomes just
<code>master
</code>).
1818 <dt class=
"hdlist1">
1823 reflog identity name
1826 <dt class=
"hdlist1">
1831 reflog identity name (respecting .mailmap, see
1832 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1835 <dt class=
"hdlist1">
1840 reflog identity email
1843 <dt class=
"hdlist1">
1848 reflog identity email (respecting .mailmap, see
1849 <a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1852 <dt class=
"hdlist1">
1860 <dt class=
"hdlist1">
1861 <em>%(trailers[:
<options
>])
</em>
1865 display the trailers of the body as interpreted by
1866 <a href=
"git-interpret-trailers.html">git-interpret-trailers(
1)
</a>. The
<code>trailers
</code> string may be followed by
1867 a colon and zero or more comma-separated options. If any option is provided
1868 multiple times, the last occurrence wins.
1870 <div class=
"ulist"><ul>
1873 <em>key=
<key
></em>: only show trailers with specified
<key
>. Matching is done
1874 case-insensitively and trailing colon is optional. If option is
1875 given multiple times trailer lines matching any of the keys are
1876 shown. This option automatically enables the
<code>only
</code> option so that
1877 non-trailer lines in the trailer block are hidden. If that is not
1878 desired it can be disabled with
<code>only=false
</code>. E.g.,
1879 <code>%(trailers:key=Reviewed-by)
</code> shows trailer lines with key
1880 <code>Reviewed-by
</code>.
1885 <em>only[=
<bool
>]
</em>: select whether non-trailer lines from the trailer
1886 block should be included.
1891 <em>separator=
<sep
></em>: specify a separator inserted between trailer
1892 lines. When this option is not given each trailer line is
1893 terminated with a line feed character. The string
<sep
> may contain
1894 the literal formatting codes described above. To use comma as
1895 separator one must use
<code>%x2C
</code> as it would otherwise be parsed as
1896 next option. E.g.,
<code>%(trailers:key=Ticket,separator=%x2C )
</code>
1897 shows all trailer lines whose key is
"Ticket" separated by a comma
1903 <em>unfold[=
<bool
>]
</em>: make it behave as if interpret-trailer
’s
<code>--unfold
</code>
1904 option was given. E.g.,
1905 <code>%(trailers:only,unfold=true)
</code> unfolds and shows all trailer lines.
1910 <em>keyonly[=
<bool
>]
</em>: only show the key part of the trailer.
1915 <em>valueonly[=
<bool
>]
</em>: only show the value part of the trailer.
1920 <em>key_value_separator=
<sep
></em>: specify a separator inserted between
1921 trailer lines. When this option is not given each trailer key-value
1922 pair is separated by
": ". Otherwise it shares the same semantics
1923 as
<em>separator=
<sep
></em> above.
1933 <div class=
"admonitionblock">
1936 <div class=
"title">Note
</div>
1938 <td class=
"content">Some placeholders may depend on other options given to the
1939 revision traversal engine. For example, the
<code>%g*
</code> reflog options will
1940 insert an empty string unless we are traversing reflog entries (e.g., by
1941 <code>git log -g
</code>). The
<code>%d
</code> and
<code>%D
</code> placeholders will use the
"short"
1942 decoration format if
<code>--decorate
</code> was not already provided on the command
1946 <div class=
"paragraph"><p>The boolean options accept an optional value
<code>[=
<bool-value
>]
</code>. The values
1947 <code>true
</code>,
<code>false
</code>,
<code>on
</code>,
<code>off
</code> etc. are all accepted. See the
"boolean"
1948 sub-section in
"EXAMPLES" in
<a href=
"git-config.html">git-config(
1)
</a>. If a boolean
1949 option is given with no value, it
’s enabled.
</p></div>
1950 <div class=
"paragraph"><p>If you add a
<code>+
</code> (plus sign) after
<em>%
</em> of a placeholder, a line-feed
1951 is inserted immediately before the expansion if and only if the
1952 placeholder expands to a non-empty string.
</p></div>
1953 <div class=
"paragraph"><p>If you add a
<code>-
</code> (minus sign) after
<em>%
</em> of a placeholder, all consecutive
1954 line-feeds immediately preceding the expansion are deleted if and only if the
1955 placeholder expands to an empty string.
</p></div>
1956 <div class=
"paragraph"><p>If you add a ` ` (space) after
<em>%
</em> of a placeholder, a space
1957 is inserted immediately before the expansion if and only if the
1958 placeholder expands to a non-empty string.
</p></div>
1959 <div class=
"ulist"><ul>
1964 <div class=
"paragraph"><p>The
<em>tformat:
</em> format works exactly like
<em>format:
</em>, except that it
1965 provides
"terminator" semantics instead of
"separator" semantics. In
1966 other words, each commit has the message terminator character (usually a
1967 newline) appended, rather than a separator placed between entries.
1968 This means that the final entry of a single-line format will be properly
1969 terminated with a new line, just as the
"oneline" format does.
1970 For example:
</p></div>
1971 <div class=
"listingblock">
1972 <div class=
"content">
1973 <pre><code>$ git log -
2 --pretty=format:%h
4da45bef \
1974 | perl -pe '$_ .=
" -- NO NEWLINE\n" unless /\n/'
1976 7134973 -- NO NEWLINE
1978 $ git log -
2 --pretty=tformat:%h
4da45bef \
1979 | perl -pe '$_ .=
" -- NO NEWLINE\n" unless /\n/'
1981 7134973</code></pre>
1983 <div class=
"paragraph"><p>In addition, any unrecognized string that has a
<code>%
</code> in it is interpreted
1984 as if it has
<code>tformat:
</code> in front of it. For example, these two are
1985 equivalent:
</p></div>
1986 <div class=
"listingblock">
1987 <div class=
"content">
1988 <pre><code>$ git log -
2 --pretty=tformat:%h
4da45bef
1989 $ git log -
2 --pretty=%h
4da45bef
</code></pre>
1996 <h2 id=
"_diff_formatting">DIFF FORMATTING
</h2>
1997 <div class=
"sectionbody">
1998 <div class=
"paragraph"><p>The options below can be used to change the way
<code>git show
</code> generates
1999 diff output.
</p></div>
2000 <div class=
"dlist"><dl>
2001 <dt class=
"hdlist1">
2004 <dt class=
"hdlist1">
2007 <dt class=
"hdlist1">
2012 Generate patch (see
<a href=
"#generate_patch_text_with_p">[generate_patch_text_with_p]
</a>).
2015 <dt class=
"hdlist1">
2018 <dt class=
"hdlist1">
2023 Suppress all output from the diff machinery. Useful for
2024 commands like
<code>git show
</code> that show the patch by default to
2025 squelch their output, or to cancel the effect of options like
2026 <code>--patch
</code>,
<code>--stat
</code> earlier on the command line in an alias.
2029 <dt class=
"hdlist1">
2034 Show diffs for merge commits in the default format. This is
2035 similar to
<em>--diff-merges=on
</em>, except
<code>-m
</code> will
2036 produce no output unless
<code>-p
</code> is given as well.
2039 <dt class=
"hdlist1">
2044 Produce combined diff output for merge commits.
2045 Shortcut for
<em>--diff-merges=combined -p
</em>.
2048 <dt class=
"hdlist1">
2053 Produce dense combined diff output for merge commits.
2054 Shortcut for
<em>--diff-merges=dense-combined -p
</em>.
2057 <dt class=
"hdlist1">
2062 Produce diff with respect to first parent for both merge and
2064 Shortcut for
<em>--diff-merges=first-parent -p
</em>.
2067 <dt class=
"hdlist1">
2072 Produce remerge-diff output for merge commits.
2073 Shortcut for
<em>--diff-merges=remerge -p
</em>.
2076 <dt class=
"hdlist1">
2081 Synonym for
<em>--diff-merges=off
</em>.
2084 <dt class=
"hdlist1">
2085 --diff-merges=
<format
>
2089 Specify diff format to be used for merge commits. Default is
2090 <code>dense-combined
</code> unless
<code>--first-parent
</code> is in use, in
2091 which case
<code>first-parent
</code> is the default.
2093 <div class=
"paragraph"><p>The following formats are supported:
</p></div>
2094 <div class=
"openblock">
2095 <div class=
"content">
2096 <div class=
"dlist"><dl>
2097 <dt class=
"hdlist1">
2102 Disable output of diffs for merge commits. Useful to override
2106 <dt class=
"hdlist1">
2111 Make diff output for merge commits to be shown in the default
2112 format. The default format can be changed using
2113 <code>log.diffMerges
</code> configuration variable, whose default value
2114 is
<code>separate
</code>.
2117 <dt class=
"hdlist1">
2122 Show full diff with respect to first parent. This is the same
2123 format as
<code>--patch
</code> produces for non-merge commits.
2126 <dt class=
"hdlist1">
2131 Show full diff with respect to each of parents.
2132 Separate log entry and diff is generated for each parent.
2135 <dt class=
"hdlist1">
2140 Show differences from each of the parents to the merge
2141 result simultaneously instead of showing pairwise diff between
2142 a parent and the result one at a time. Furthermore, it lists
2143 only files which were modified from all parents.
2146 <dt class=
"hdlist1">
2151 Further compress output produced by
<code>--diff-merges=combined
</code>
2152 by omitting uninteresting hunks whose contents in the parents
2153 have only two variants and the merge result picks one of them
2154 without modification.
2157 <dt class=
"hdlist1">
2162 Remerge two-parent merge commits to create a temporary tree
2163 object
—potentially containing files with conflict markers
2164 and such. A diff is then shown between that temporary tree
2165 and the actual merge commit.
2167 <div class=
"paragraph"><p>The output emitted when this option is used is subject to change, and
2168 so is its interaction with other options (unless explicitly
2169 documented).
</p></div>
2174 <dt class=
"hdlist1">
2175 --combined-all-paths
2179 This flag causes combined diffs (used for merge commits) to
2180 list the name of the file from all parents. It thus only has
2181 effect when
<code>--diff-merges=[dense-]combined
</code> is in use, and
2182 is likely only useful if filename changes are detected (i.e.
2183 when either rename or copy detection have been requested).
2186 <dt class=
"hdlist1">
2189 <dt class=
"hdlist1">
2194 Generate diffs with
<n
> lines of context instead of
2196 Implies
<code>--patch
</code>.
2199 <dt class=
"hdlist1">
2200 --output=
<file
>
2204 Output to a specific file instead of stdout.
2207 <dt class=
"hdlist1">
2208 --output-indicator-new=
<char
>
2210 <dt class=
"hdlist1">
2211 --output-indicator-old=
<char
>
2213 <dt class=
"hdlist1">
2214 --output-indicator-context=
<char
>
2218 Specify the character used to indicate new, old or context
2219 lines in the generated patch. Normally they are
<em>+
</em>,
<em>-
</em> and
2223 <dt class=
"hdlist1">
2228 For each commit, show a summary of changes using the raw diff
2229 format. See the
"RAW OUTPUT FORMAT" section of
2230 <a href=
"git-diff.html">git-diff(
1)
</a>. This is different from showing the log
2231 itself in raw format, which you can achieve with
2232 <code>--format=raw
</code>.
2235 <dt class=
"hdlist1">
2240 Synonym for
<code>-p --raw
</code>.
2243 <dt class=
"hdlist1">
2248 Show the tree objects in the diff output.
2251 <dt class=
"hdlist1">
2256 Enable the heuristic that shifts diff hunk boundaries to make patches
2257 easier to read. This is the default.
2260 <dt class=
"hdlist1">
2261 --no-indent-heuristic
2265 Disable the indent heuristic.
2268 <dt class=
"hdlist1">
2273 Spend extra time to make sure the smallest possible
2277 <dt class=
"hdlist1">
2282 Generate a diff using the
"patience diff" algorithm.
2285 <dt class=
"hdlist1">
2290 Generate a diff using the
"histogram diff" algorithm.
2293 <dt class=
"hdlist1">
2294 --anchored=
<text
>
2298 Generate a diff using the
"anchored diff" algorithm.
2300 <div class=
"paragraph"><p>This option may be specified more than once.
</p></div>
2301 <div class=
"paragraph"><p>If a line exists in both the source and destination, exists only once,
2302 and starts with this text, this algorithm attempts to prevent it from
2303 appearing as a deletion or addition in the output. It uses the
"patience
2304 diff" algorithm internally.
</p></div>
2306 <dt class=
"hdlist1">
2307 --diff-algorithm={patience|minimal|histogram|myers}
2311 Choose a diff algorithm. The variants are as follows:
2313 <div class=
"openblock">
2314 <div class=
"content">
2315 <div class=
"dlist"><dl>
2316 <dt class=
"hdlist1">
2317 <code>default
</code>,
<code>myers
</code>
2321 The basic greedy diff algorithm. Currently, this is the default.
2324 <dt class=
"hdlist1">
2325 <code>minimal
</code>
2329 Spend extra time to make sure the smallest possible diff is
2333 <dt class=
"hdlist1">
2334 <code>patience
</code>
2338 Use
"patience diff" algorithm when generating patches.
2341 <dt class=
"hdlist1">
2342 <code>histogram
</code>
2346 This algorithm extends the patience algorithm to
"support
2347 low-occurrence common elements".
2352 <div class=
"paragraph"><p>For instance, if you configured the
<code>diff.algorithm
</code> variable to a
2353 non-default value and want to use the default one, then you
2354 have to use
<code>--diff-algorithm=default
</code> option.
</p></div>
2356 <dt class=
"hdlist1">
2357 --stat[=
<width
>[,
<name-width
>[,
<count
>]]]
2361 Generate a diffstat. By default, as much space as necessary
2362 will be used for the filename part, and the rest for the graph
2363 part. Maximum width defaults to terminal width, or
80 columns
2364 if not connected to a terminal, and can be overridden by
2365 <code><width
></code>. The width of the filename part can be limited by
2366 giving another width
<code><name-width
></code> after a comma or by setting
2367 <code>diff.statNameWidth=
<width
></code>. The width of the graph part can be
2368 limited by using
<code>--stat-graph-width=
<width
></code> or by setting
2369 <code>diff.statGraphWidth=
<width
></code>. Using
<code>--stat
</code> or
2370 <code>--stat-graph-width
</code> affects all commands generating a stat graph,
2371 while setting
<code>diff.statNameWidth
</code> or
<code>diff.statGraphWidth
</code>
2372 does not affect
<code>git format-patch
</code>.
2373 By giving a third parameter
<code><count
></code>, you can limit the output to
2374 the first
<code><count
></code> lines, followed by
<code>...
</code> if there are more.
2376 <div class=
"paragraph"><p>These parameters can also be set individually with
<code>--stat-width=
<width
></code>,
2377 <code>--stat-name-width=
<name-width
></code> and
<code>--stat-count=
<count
></code>.
</p></div>
2379 <dt class=
"hdlist1">
2384 Output a condensed summary of extended header information such
2385 as file creations or deletions (
"new" or
"gone", optionally
"+l"
2386 if it
’s a symlink) and mode changes (
"+x" or
"-x" for adding
2387 or removing executable bit respectively) in diffstat. The
2388 information is put between the filename part and the graph
2389 part. Implies
<code>--stat
</code>.
2392 <dt class=
"hdlist1">
2397 Similar to
<code>--stat
</code>, but shows number of added and
2398 deleted lines in decimal notation and pathname without
2399 abbreviation, to make it more machine friendly. For
2400 binary files, outputs two
<code>-
</code> instead of saying
2404 <dt class=
"hdlist1">
2409 Output only the last line of the
<code>--stat
</code> format containing total
2410 number of modified files, as well as number of added and deleted
2414 <dt class=
"hdlist1">
2415 -X[
<param1,param2,
…>]
2417 <dt class=
"hdlist1">
2418 --dirstat[=
<param1,param2,
…>]
2422 Output the distribution of relative amount of changes for each
2423 sub-directory. The behavior of
<code>--dirstat
</code> can be customized by
2424 passing it a comma separated list of parameters.
2425 The defaults are controlled by the
<code>diff.dirstat
</code> configuration
2426 variable (see
<a href=
"git-config.html">git-config(
1)
</a>).
2427 The following parameters are available:
2429 <div class=
"openblock">
2430 <div class=
"content">
2431 <div class=
"dlist"><dl>
2432 <dt class=
"hdlist1">
2433 <code>changes
</code>
2437 Compute the dirstat numbers by counting the lines that have been
2438 removed from the source, or added to the destination. This ignores
2439 the amount of pure code movements within a file. In other words,
2440 rearranging lines in a file is not counted as much as other changes.
2441 This is the default behavior when no parameter is given.
2444 <dt class=
"hdlist1">
2449 Compute the dirstat numbers by doing the regular line-based diff
2450 analysis, and summing the removed/added line counts. (For binary
2451 files, count
64-byte chunks instead, since binary files have no
2452 natural concept of lines). This is a more expensive
<code>--dirstat
</code>
2453 behavior than the
<code>changes
</code> behavior, but it does count rearranged
2454 lines within a file as much as other changes. The resulting output
2455 is consistent with what you get from the other
<code>--*stat
</code> options.
2458 <dt class=
"hdlist1">
2463 Compute the dirstat numbers by counting the number of files changed.
2464 Each changed file counts equally in the dirstat analysis. This is
2465 the computationally cheapest
<code>--dirstat
</code> behavior, since it does
2466 not have to look at the file contents at all.
2469 <dt class=
"hdlist1">
2470 <code>cumulative
</code>
2474 Count changes in a child directory for the parent directory as well.
2475 Note that when using
<code>cumulative
</code>, the sum of the percentages
2476 reported may exceed
100%. The default (non-cumulative) behavior can
2477 be specified with the
<code>noncumulative
</code> parameter.
2480 <dt class=
"hdlist1">
2485 An integer parameter specifies a cut-off percent (
3% by default).
2486 Directories contributing less than this percentage of the changes
2487 are not shown in the output.
2492 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
2493 directories with less than
10% of the total amount of changed files,
2494 and accumulating child directory counts in the parent directories:
2495 <code>--dirstat=files,
10,cumulative
</code>.
</p></div>
2497 <dt class=
"hdlist1">
2502 Synonym for --dirstat=cumulative
2505 <dt class=
"hdlist1">
2506 --dirstat-by-file[=
<param1,param2
>…]
2510 Synonym for --dirstat=files,
<param1
>,
<param2
>…
2513 <dt class=
"hdlist1">
2518 Output a condensed summary of extended header information
2519 such as creations, renames and mode changes.
2522 <dt class=
"hdlist1">
2527 Synonym for
<code>-p --stat
</code>.
2530 <dt class=
"hdlist1">
2535 Separate the commits with NULs instead of newlines.
2537 <div class=
"paragraph"><p>Also, when
<code>--raw
</code> or
<code>--numstat
</code> has been given, do not munge
2538 pathnames and use NULs as output field terminators.
</p></div>
2539 <div class=
"paragraph"><p>Without this option, pathnames with
"unusual" characters are quoted as
2540 explained for the configuration variable
<code>core.quotePath
</code> (see
2541 <a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
2543 <dt class=
"hdlist1">
2548 Show only names of changed files. The file names are often encoded in UTF-
8.
2549 For more information see the discussion about encoding in the
<a href=
"git-log.html">git-log(
1)
</a>
2553 <dt class=
"hdlist1">
2558 Show only names and status of changed files. See the description
2559 of the
<code>--diff-filter
</code> option on what the status letters mean.
2560 Just like
<code>--name-only
</code> the file names are often encoded in UTF-
8.
2563 <dt class=
"hdlist1">
2564 --submodule[=
<format
>]
2568 Specify how differences in submodules are shown. When specifying
2569 <code>--submodule=short
</code> the
<em>short
</em> format is used. This format just
2570 shows the names of the commits at the beginning and end of the range.
2571 When
<code>--submodule
</code> or
<code>--submodule=log
</code> is specified, the
<em>log
</em>
2572 format is used. This format lists the commits in the range like
2573 <a href=
"git-submodule.html">git-submodule(
1)
</a> <code>summary
</code> does. When
<code>--submodule=diff
</code>
2574 is specified, the
<em>diff
</em> format is used. This format shows an
2575 inline diff of the changes in the submodule contents between the
2576 commit range. Defaults to
<code>diff.submodule
</code> or the
<em>short
</em> format
2577 if the config option is unset.
2580 <dt class=
"hdlist1">
2581 --color[=
<when
>]
2586 <code>--color
</code> (i.e. without
<em>=
<when
></em>) is the same as
<code>--color=always
</code>.
2587 <em><when
></em> can be one of
<code>always
</code>,
<code>never
</code>, or
<code>auto
</code>.
2590 <dt class=
"hdlist1">
2595 Turn off colored diff.
2596 It is the same as
<code>--color=never
</code>.
2599 <dt class=
"hdlist1">
2600 --color-moved[=
<mode
>]
2604 Moved lines of code are colored differently.
2605 The
<mode
> defaults to
<em>no
</em> if the option is not given
2606 and to
<em>zebra
</em> if the option with no mode is given.
2607 The mode must be one of:
2609 <div class=
"openblock">
2610 <div class=
"content">
2611 <div class=
"dlist"><dl>
2612 <dt class=
"hdlist1">
2617 Moved lines are not highlighted.
2620 <dt class=
"hdlist1">
2625 Is a synonym for
<code>zebra
</code>. This may change to a more sensible mode
2629 <dt class=
"hdlist1">
2634 Any line that is added in one location and was removed
2635 in another location will be colored with
<em>color.diff.newMoved
</em>.
2636 Similarly
<em>color.diff.oldMoved
</em> will be used for removed lines
2637 that are added somewhere else in the diff. This mode picks up any
2638 moved line, but it is not very useful in a review to determine
2639 if a block of code was moved without permutation.
2642 <dt class=
"hdlist1">
2647 Blocks of moved text of at least
20 alphanumeric characters
2648 are detected greedily. The detected blocks are
2649 painted using either the
<em>color.diff.{old,new}Moved
</em> color.
2650 Adjacent blocks cannot be told apart.
2653 <dt class=
"hdlist1">
2658 Blocks of moved text are detected as in
<em>blocks
</em> mode. The blocks
2659 are painted using either the
<em>color.diff.{old,new}Moved
</em> color or
2660 <em>color.diff.{old,new}MovedAlternative
</em>. The change between
2661 the two colors indicates that a new block was detected.
2664 <dt class=
"hdlist1">
2669 Similar to
<em>zebra
</em>, but additional dimming of uninteresting parts
2670 of moved code is performed. The bordering lines of two adjacent
2671 blocks are considered interesting, the rest is uninteresting.
2672 <code>dimmed_zebra
</code> is a deprecated synonym.
2678 <dt class=
"hdlist1">
2683 Turn off move detection. This can be used to override configuration
2684 settings. It is the same as
<code>--color-moved=no
</code>.
2687 <dt class=
"hdlist1">
2688 --color-moved-ws=
<modes
>
2692 This configures how whitespace is ignored when performing the
2693 move detection for
<code>--color-moved
</code>.
2694 These modes can be given as a comma separated list:
2696 <div class=
"openblock">
2697 <div class=
"content">
2698 <div class=
"dlist"><dl>
2699 <dt class=
"hdlist1">
2704 Do not ignore whitespace when performing move detection.
2707 <dt class=
"hdlist1">
2712 Ignore changes in whitespace at EOL.
2715 <dt class=
"hdlist1">
2720 Ignore changes in amount of whitespace. This ignores whitespace
2721 at line end, and considers all other sequences of one or
2722 more whitespace characters to be equivalent.
2725 <dt class=
"hdlist1">
2730 Ignore whitespace when comparing lines. This ignores differences
2731 even if one line has whitespace where the other line has none.
2734 <dt class=
"hdlist1">
2735 allow-indentation-change
2739 Initially ignore any whitespace in the move detection, then
2740 group the moved code blocks only into a block if the change in
2741 whitespace is the same per line. This is incompatible with the
2748 <dt class=
"hdlist1">
2753 Do not ignore whitespace when performing move detection. This can be
2754 used to override configuration settings. It is the same as
2755 <code>--color-moved-ws=no
</code>.
2758 <dt class=
"hdlist1">
2759 --word-diff[=
<mode
>]
2763 Show a word diff, using the
<mode
> to delimit changed words.
2764 By default, words are delimited by whitespace; see
2765 <code>--word-diff-regex
</code> below. The
<mode
> defaults to
<em>plain
</em>, and
2768 <div class=
"openblock">
2769 <div class=
"content">
2770 <div class=
"dlist"><dl>
2771 <dt class=
"hdlist1">
2776 Highlight changed words using only colors. Implies
<code>--color
</code>.
2779 <dt class=
"hdlist1">
2784 Show words as
<code>[-removed-]
</code> and
<code>{+added+}
</code>. Makes no
2785 attempts to escape the delimiters if they appear in the input,
2786 so the output may be ambiguous.
2789 <dt class=
"hdlist1">
2794 Use a special line-based format intended for script
2795 consumption. Added/removed/unchanged runs are printed in the
2796 usual unified diff format, starting with a
<code>+
</code>/
<code>-
</code>/` `
2797 character at the beginning of the line and extending to the
2798 end of the line. Newlines in the input are represented by a
2799 tilde
<code>~
</code> on a line of its own.
2802 <dt class=
"hdlist1">
2807 Disable word diff again.
2812 <div class=
"paragraph"><p>Note that despite the name of the first mode, color is used to
2813 highlight the changed parts in all modes if enabled.
</p></div>
2815 <dt class=
"hdlist1">
2816 --word-diff-regex=
<regex
>
2820 Use
<regex
> to decide what a word is, instead of considering
2821 runs of non-whitespace to be a word. Also implies
2822 <code>--word-diff
</code> unless it was already enabled.
2824 <div class=
"paragraph"><p>Every non-overlapping match of the
2825 <regex
> is considered a word. Anything between these matches is
2826 considered whitespace and ignored(!) for the purposes of finding
2827 differences. You may want to append
<code>|[^[:space:]]
</code> to your regular
2828 expression to make sure that it matches all non-whitespace characters.
2829 A match that contains a newline is silently truncated(!) at the
2831 <div class=
"paragraph"><p>For example,
<code>--word-diff-regex=.
</code> will treat each character as a word
2832 and, correspondingly, show differences character by character.
</p></div>
2833 <div class=
"paragraph"><p>The regex can also be set via a diff driver or configuration option, see
2834 <a href=
"gitattributes.html">gitattributes(
5)
</a> or
<a href=
"git-config.html">git-config(
1)
</a>. Giving it explicitly
2835 overrides any diff driver or configuration setting. Diff drivers
2836 override configuration settings.
</p></div>
2838 <dt class=
"hdlist1">
2839 --color-words[=
<regex
>]
2843 Equivalent to
<code>--word-diff=color
</code> plus (if a regex was
2844 specified)
<code>--word-diff-regex=
<regex
></code>.
2847 <dt class=
"hdlist1">
2852 Turn off rename detection, even when the configuration
2853 file gives the default to do so.
2856 <dt class=
"hdlist1">
2861 Whether to use empty blobs as rename source.
2864 <dt class=
"hdlist1">
2869 Warn if changes introduce conflict markers or whitespace errors.
2870 What are considered whitespace errors is controlled by
<code>core.whitespace
</code>
2871 configuration. By default, trailing whitespaces (including
2872 lines that consist solely of whitespaces) and a space character
2873 that is immediately followed by a tab character inside the
2874 initial indent of the line are considered whitespace errors.
2875 Exits with non-zero status if problems are found. Not compatible
2879 <dt class=
"hdlist1">
2880 --ws-error-highlight=
<kind
>
2884 Highlight whitespace errors in the
<code>context
</code>,
<code>old
</code> or
<code>new
</code>
2885 lines of the diff. Multiple values are separated by comma,
2886 <code>none
</code> resets previous values,
<code>default
</code> reset the list to
2887 <code>new
</code> and
<code>all
</code> is a shorthand for
<code>old,new,context
</code>. When
2888 this option is not given, and the configuration variable
2889 <code>diff.wsErrorHighlight
</code> is not set, only whitespace errors in
2890 <code>new
</code> lines are highlighted. The whitespace errors are colored
2891 with
<code>color.diff.whitespace
</code>.
2894 <dt class=
"hdlist1">
2899 Instead of the first handful of characters, show the full
2900 pre- and post-image blob object names on the
"index"
2901 line when generating patch format output.
2904 <dt class=
"hdlist1">
2909 In addition to
<code>--full-index
</code>, output a binary diff that
2910 can be applied with
<code>git-apply
</code>.
2911 Implies
<code>--patch
</code>.
2914 <dt class=
"hdlist1">
2915 --abbrev[=
<n
>]
2919 Instead of showing the full
40-byte hexadecimal object
2920 name in diff-raw format output and diff-tree header
2921 lines, show the shortest prefix that is at least
<em><n
></em>
2922 hexdigits long that uniquely refers the object.
2923 In diff-patch output format,
<code>--full-index
</code> takes higher
2924 precedence, i.e. if
<code>--full-index
</code> is specified, full blob
2925 names will be shown regardless of
<code>--abbrev
</code>.
2926 Non default number of digits can be specified with
<code>--abbrev=
<n
></code>.
2929 <dt class=
"hdlist1">
2930 -B[
<n
>][/
<m
>]
2932 <dt class=
"hdlist1">
2933 --break-rewrites[=[
<n
>][/
<m
>]]
2937 Break complete rewrite changes into pairs of delete and
2938 create. This serves two purposes:
2940 <div class=
"paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
2941 not as a series of deletion and insertion mixed together with a very
2942 few lines that happen to match textually as the context, but as a
2943 single deletion of everything old followed by a single insertion of
2944 everything new, and the number
<code>m
</code> controls this aspect of the -B
2945 option (defaults to
60%).
<code>-B/
70%
</code> specifies that less than
30% of the
2946 original should remain in the result for Git to consider it a total
2947 rewrite (i.e. otherwise the resulting patch will be a series of
2948 deletion and insertion mixed together with context lines).
</p></div>
2949 <div class=
"paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
2950 source of a rename (usually -M only considers a file that disappeared
2951 as the source of a rename), and the number
<code>n
</code> controls this aspect of
2952 the -B option (defaults to
50%).
<code>-B20%
</code> specifies that a change with
2953 addition and deletion compared to
20% or more of the file
’s size are
2954 eligible for being picked up as a possible source of a rename to
2955 another file.
</p></div>
2957 <dt class=
"hdlist1">
2960 <dt class=
"hdlist1">
2961 --find-renames[=
<n
>]
2965 If generating diffs, detect and report renames for each commit.
2966 For following files across renames while traversing history, see
2967 <code>--follow
</code>.
2968 If
<code>n
</code> is specified, it is a threshold on the similarity
2969 index (i.e. amount of addition/deletions compared to the
2970 file
’s size). For example,
<code>-M90%
</code> means Git should consider a
2971 delete/add pair to be a rename if more than
90% of the file
2972 hasn
’t changed. Without a
<code>%
</code> sign, the number is to be read as
2973 a fraction, with a decimal point before it. I.e.,
<code>-M5
</code> becomes
2974 0.5, and is thus the same as
<code>-M50%
</code>. Similarly,
<code>-M05
</code> is
2975 the same as
<code>-M5%
</code>. To limit detection to exact renames, use
2976 <code>-M100%
</code>. The default similarity index is
50%.
2979 <dt class=
"hdlist1">
2982 <dt class=
"hdlist1">
2983 --find-copies[=
<n
>]
2987 Detect copies as well as renames. See also
<code>--find-copies-harder
</code>.
2988 If
<code>n
</code> is specified, it has the same meaning as for
<code>-M
<n
></code>.
2991 <dt class=
"hdlist1">
2992 --find-copies-harder
2996 For performance reasons, by default,
<code>-C
</code> option finds copies only
2997 if the original file of the copy was modified in the same
2998 changeset. This flag makes the command
2999 inspect unmodified files as candidates for the source of
3000 copy. This is a very expensive operation for large
3001 projects, so use it with caution. Giving more than one
3002 <code>-C
</code> option has the same effect.
3005 <dt class=
"hdlist1">
3008 <dt class=
"hdlist1">
3009 --irreversible-delete
3013 Omit the preimage for deletes, i.e. print only the header but not
3014 the diff between the preimage and
<code>/dev/null
</code>. The resulting patch
3015 is not meant to be applied with
<code>patch
</code> or
<code>git apply
</code>; this is
3016 solely for people who want to just concentrate on reviewing the
3017 text after the change. In addition, the output obviously lacks
3018 enough information to apply such a patch in reverse, even manually,
3019 hence the name of the option.
3021 <div class=
"paragraph"><p>When used together with
<code>-B
</code>, omit also the preimage in the deletion part
3022 of a delete/create pair.
</p></div>
3024 <dt class=
"hdlist1">
3029 The
<code>-M
</code> and
<code>-C
</code> options involve some preliminary steps that
3030 can detect subsets of renames/copies cheaply, followed by an
3031 exhaustive fallback portion that compares all remaining
3032 unpaired destinations to all relevant sources. (For renames,
3033 only remaining unpaired sources are relevant; for copies, all
3034 original sources are relevant.) For N sources and
3035 destinations, this exhaustive check is O(N^
2). This option
3036 prevents the exhaustive portion of rename/copy detection from
3037 running if the number of source/destination files involved
3038 exceeds the specified number. Defaults to diff.renameLimit.
3039 Note that a value of
0 is treated as unlimited.
3042 <dt class=
"hdlist1">
3043 --diff-filter=[(A|C|D|M|R|T|U|X|B)
…[*]]
3047 Select only files that are Added (
<code>A
</code>), Copied (
<code>C
</code>),
3048 Deleted (
<code>D
</code>), Modified (
<code>M
</code>), Renamed (
<code>R
</code>), have their
3049 type (i.e. regular file, symlink, submodule,
…) changed (
<code>T
</code>),
3050 are Unmerged (
<code>U
</code>), are
3051 Unknown (
<code>X
</code>), or have had their pairing Broken (
<code>B
</code>).
3052 Any combination of the filter characters (including none) can be used.
3053 When
<code>*
</code> (All-or-none) is added to the combination, all
3054 paths are selected if there is any file that matches
3055 other criteria in the comparison; if there is no file
3056 that matches other criteria, nothing is selected.
3058 <div class=
"paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
3059 <code>--diff-filter=ad
</code> excludes added and deleted paths.
</p></div>
3060 <div class=
"paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
3061 renamed entries cannot appear if detection for those types is disabled.
</p></div>
3063 <dt class=
"hdlist1">
3068 Look for differences that change the number of occurrences of
3069 the specified string (i.e. addition/deletion) in a file.
3070 Intended for the scripter
’s use.
3072 <div class=
"paragraph"><p>It is useful when you
’re looking for an exact block of code (like a
3073 struct), and want to know the history of that block since it first
3074 came into being: use the feature iteratively to feed the interesting
3075 block in the preimage back into
<code>-S
</code>, and keep going until you get the
3076 very first version of the block.
</p></div>
3077 <div class=
"paragraph"><p>Binary files are searched as well.
</p></div>
3079 <dt class=
"hdlist1">
3084 Look for differences whose patch text contains added/removed
3085 lines that match
<regex
>.
3087 <div class=
"paragraph"><p>To illustrate the difference between
<code>-S
<regex
> --pickaxe-regex
</code> and
3088 <code>-G
<regex
></code>, consider a commit with the following diff in the same
3090 <div class=
"listingblock">
3091 <div class=
"content">
3092 <pre><code>+ return frotz(nitfol, two-
>ptr,
1,
0);
3094 - hit = frotz(nitfol, mf2.ptr,
1,
0);
</code></pre>
3096 <div class=
"paragraph"><p>While
<code>git log -G
"frotz\(nitfol"</code> will show this commit,
<code>git log
3097 -S
"frotz\(nitfol" --pickaxe-regex
</code> will not (because the number of
3098 occurrences of that string did not change).
</p></div>
3099 <div class=
"paragraph"><p>Unless
<code>--text
</code> is supplied patches of binary files without a textconv
3100 filter will be ignored.
</p></div>
3101 <div class=
"paragraph"><p>See the
<em>pickaxe
</em> entry in
<a href=
"gitdiffcore.html">gitdiffcore(
7)
</a> for more
3102 information.
</p></div>
3104 <dt class=
"hdlist1">
3105 --find-object=
<object-id
>
3109 Look for differences that change the number of occurrences of
3110 the specified object. Similar to
<code>-S
</code>, just the argument is different
3111 in that it doesn
’t search for a specific string but for a specific
3114 <div class=
"paragraph"><p>The object can be a blob or a submodule commit. It implies the
<code>-t
</code> option in
3115 <code>git-log
</code> to also find trees.
</p></div>
3117 <dt class=
"hdlist1">
3122 When
<code>-S
</code> or
<code>-G
</code> finds a change, show all the changes in that
3123 changeset, not just the files that contain the change
3127 <dt class=
"hdlist1">
3132 Treat the
<string
> given to
<code>-S
</code> as an extended POSIX regular
3133 expression to match.
3136 <dt class=
"hdlist1">
3141 Control the order in which files appear in the output.
3142 This overrides the
<code>diff.orderFile
</code> configuration variable
3143 (see
<a href=
"git-config.html">git-config(
1)
</a>). To cancel
<code>diff.orderFile
</code>,
3144 use
<code>-O/dev/null
</code>.
3146 <div class=
"paragraph"><p>The output order is determined by the order of glob patterns in
3148 All files with pathnames that match the first pattern are output
3149 first, all files with pathnames that match the second pattern (but not
3150 the first) are output next, and so on.
3151 All files with pathnames that do not match any pattern are output
3152 last, as if there was an implicit match-all pattern at the end of the
3154 If multiple pathnames have the same rank (they match the same pattern
3155 but no earlier patterns), their output order relative to each other is
3156 the normal order.
</p></div>
3157 <div class=
"paragraph"><p><orderfile
> is parsed as follows:
</p></div>
3158 <div class=
"openblock">
3159 <div class=
"content">
3160 <div class=
"ulist"><ul>
3163 Blank lines are ignored, so they can be used as separators for
3169 Lines starting with a hash (
"<code>#</code>") are ignored, so they can be used
3170 for comments. Add a backslash (
"<code>\</code>") to the beginning of the
3171 pattern if it starts with a hash.
3176 Each other line contains a single pattern.
3181 <div class=
"paragraph"><p>Patterns have the same syntax and semantics as patterns used for
3182 fnmatch(
3) without the FNM_PATHNAME flag, except a pathname also
3183 matches a pattern if removing any number of the final pathname
3184 components matches the pattern. For example, the pattern
"<code>foo*bar</code>"
3185 matches
"<code>fooasdfbar</code>" and
"<code>foo/bar/baz/asdf</code>" but not
"<code>foobarx</code>".
</p></div>
3187 <dt class=
"hdlist1">
3188 --skip-to=
<file
>
3190 <dt class=
"hdlist1">
3191 --rotate-to=
<file
>
3195 Discard the files before the named
<file
> from the output
3196 (i.e.
<em>skip to
</em>), or move them to the end of the output
3197 (i.e.
<em>rotate to
</em>). These options were invented primarily for the use
3198 of the
<code>git difftool
</code> command, and may not be very useful
3202 <dt class=
"hdlist1">
3207 Swap two inputs; that is, show differences from index or
3208 on-disk file to tree contents.
3211 <dt class=
"hdlist1">
3212 --relative[=
<path
>]
3214 <dt class=
"hdlist1">
3219 When run from a subdirectory of the project, it can be
3220 told to exclude changes outside the directory and show
3221 pathnames relative to it with this option. When you are
3222 not in a subdirectory (e.g. in a bare repository), you
3223 can name which subdirectory to make the output relative
3224 to by giving a
<path
> as an argument.
3225 <code>--no-relative
</code> can be used to countermand both
<code>diff.relative
</code> config
3226 option and previous
<code>--relative
</code>.
3229 <dt class=
"hdlist1">
3232 <dt class=
"hdlist1">
3237 Treat all files as text.
3240 <dt class=
"hdlist1">
3245 Ignore carriage-return at the end of line when doing a comparison.
3248 <dt class=
"hdlist1">
3249 --ignore-space-at-eol
3253 Ignore changes in whitespace at EOL.
3256 <dt class=
"hdlist1">
3259 <dt class=
"hdlist1">
3260 --ignore-space-change
3264 Ignore changes in amount of whitespace. This ignores whitespace
3265 at line end, and considers all other sequences of one or
3266 more whitespace characters to be equivalent.
3269 <dt class=
"hdlist1">
3272 <dt class=
"hdlist1">
3277 Ignore whitespace when comparing lines. This ignores
3278 differences even if one line has whitespace where the other
3282 <dt class=
"hdlist1">
3283 --ignore-blank-lines
3287 Ignore changes whose lines are all blank.
3290 <dt class=
"hdlist1">
3293 <dt class=
"hdlist1">
3294 --ignore-matching-lines=
<regex
>
3298 Ignore changes whose all lines match
<regex
>. This option may
3299 be specified more than once.
3302 <dt class=
"hdlist1">
3303 --inter-hunk-context=
<lines
>
3307 Show the context between diff hunks, up to the specified number
3308 of lines, thereby fusing hunks that are close to each other.
3309 Defaults to
<code>diff.interHunkContext
</code> or
0 if the config option
3313 <dt class=
"hdlist1">
3316 <dt class=
"hdlist1">
3321 Show whole function as context lines for each change.
3322 The function names are determined in the same way as
3323 <code>git diff
</code> works out patch hunk headers (see
<em>Defining a
3324 custom hunk-header
</em> in
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
3327 <dt class=
"hdlist1">
3332 Allow an external diff helper to be executed. If you set an
3333 external diff driver with
<a href=
"gitattributes.html">gitattributes(
5)
</a>, you need
3334 to use this option with
<a href=
"git-log.html">git-log(
1)
</a> and friends.
3337 <dt class=
"hdlist1">
3342 Disallow external diff drivers.
3345 <dt class=
"hdlist1">
3348 <dt class=
"hdlist1">
3353 Allow (or disallow) external text conversion filters to be run
3354 when comparing binary files. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for
3355 details. Because textconv filters are typically a one-way
3356 conversion, the resulting diff is suitable for human
3357 consumption, but cannot be applied. For this reason, textconv
3358 filters are enabled by default only for
<a href=
"git-diff.html">git-diff(
1)
</a> and
3359 <a href=
"git-log.html">git-log(
1)
</a>, but not for
<a href=
"git-format-patch.html">git-format-patch(
1)
</a> or
3360 diff plumbing commands.
3363 <dt class=
"hdlist1">
3364 --ignore-submodules[=
<when
>]
3368 Ignore changes to submodules in the diff generation.
<when
> can be
3369 either
"none",
"untracked",
"dirty" or
"all", which is the default.
3370 Using
"none" will consider the submodule modified when it either contains
3371 untracked or modified files or its HEAD differs from the commit recorded
3372 in the superproject and can be used to override any settings of the
3373 <em>ignore
</em> option in
<a href=
"git-config.html">git-config(
1)
</a> or
<a href=
"gitmodules.html">gitmodules(
5)
</a>. When
3374 "untracked" is used submodules are not considered dirty when they only
3375 contain untracked content (but they are still scanned for modified
3376 content). Using
"dirty" ignores all changes to the work tree of submodules,
3377 only changes to the commits stored in the superproject are shown (this was
3378 the behavior until
1.7.0). Using
"all" hides all changes to submodules.
3381 <dt class=
"hdlist1">
3382 --src-prefix=
<prefix
>
3386 Show the given source prefix instead of
"a/".
3389 <dt class=
"hdlist1">
3390 --dst-prefix=
<prefix
>
3394 Show the given destination prefix instead of
"b/".
3397 <dt class=
"hdlist1">
3402 Do not show any source or destination prefix.
3405 <dt class=
"hdlist1">
3410 Use the default source and destination prefixes (
"a/" and
"b/").
3411 This is usually the default already, but may be used to override
3412 config such as
<code>diff.noprefix
</code>.
3415 <dt class=
"hdlist1">
3416 --line-prefix=
<prefix
>
3420 Prepend an additional prefix to every line of output.
3423 <dt class=
"hdlist1">
3424 --ita-invisible-in-index
3428 By default entries added by
"git add -N" appear as an existing
3429 empty file in
"git diff" and a new file in
"git diff --cached".
3430 This option makes the entry appear as a new file in
"git diff"
3431 and non-existent in
"git diff --cached". This option could be
3432 reverted with
<code>--ita-visible-in-index
</code>. Both options are
3433 experimental and could be removed in future.
3437 <div class=
"paragraph"><p>For more detailed explanation on these common options, see also
3438 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>.
</p></div>
3442 <h2 id=
"generate_patch_text_with_p">Generating patch text with -p
</h2>
3443 <div class=
"sectionbody">
3444 <div class=
"paragraph"><p>Running
3445 <a href=
"git-diff.html">git-diff(
1)
</a>,
3446 <a href=
"git-log.html">git-log(
1)
</a>,
3447 <a href=
"git-show.html">git-show(
1)
</a>,
3448 <a href=
"git-diff-index.html">git-diff-index(
1)
</a>,
3449 <a href=
"git-diff-tree.html">git-diff-tree(
1)
</a>, or
3450 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>
3451 with the
<code>-p
</code> option produces patch text.
3452 You can customize the creation of patch text via the
3453 <code>GIT_EXTERNAL_DIFF
</code> and the
<code>GIT_DIFF_OPTS
</code> environment variables
3454 (see
<a href=
"git.html">git(
1)
</a>), and the
<code>diff
</code> attribute (see
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
</p></div>
3455 <div class=
"paragraph"><p>What the -p option produces is slightly different from the traditional
3456 diff format:
</p></div>
3457 <div class=
"olist arabic"><ol class=
"arabic">
3460 It is preceded by a
"git diff" header that looks like this:
3462 <div class=
"literalblock">
3463 <div class=
"content">
3464 <pre><code>diff --git a/file1 b/file2
</code></pre>
3466 <div class=
"paragraph"><p>The
<code>a/
</code> and
<code>b/
</code> filenames are the same unless rename/copy is
3467 involved. Especially, even for a creation or a deletion,
3468 <code>/dev/null
</code> is
<em>not
</em> used in place of the
<code>a/
</code> or
<code>b/
</code> filenames.
</p></div>
3469 <div class=
"paragraph"><p>When a rename/copy is involved,
<code>file1
</code> and
<code>file2
</code> show the
3470 name of the source file of the rename/copy and the name of
3471 the file that the rename/copy produces, respectively.
</p></div>
3475 It is followed by one or more extended header lines:
3477 <div class=
"literalblock">
3478 <div class=
"content">
3479 <pre><code>old mode
<mode
>
3480 new mode
<mode
>
3481 deleted file mode
<mode
>
3482 new file mode
<mode
>
3483 copy from
<path
>
3484 copy to
<path
>
3485 rename from
<path
>
3486 rename to
<path
>
3487 similarity index
<number
>
3488 dissimilarity index
<number
>
3489 index
<hash
>..
<hash
> <mode
></code></pre>
3491 <div class=
"paragraph"><p>File modes are printed as
6-digit octal numbers including the file type
3492 and file permission bits.
</p></div>
3493 <div class=
"paragraph"><p>Path names in extended headers do not include the
<code>a/
</code> and
<code>b/
</code> prefixes.
</p></div>
3494 <div class=
"paragraph"><p>The similarity index is the percentage of unchanged lines, and
3495 the dissimilarity index is the percentage of changed lines. It
3496 is a rounded down integer, followed by a percent sign. The
3497 similarity index value of
100% is thus reserved for two equal
3498 files, while
100% dissimilarity means that no line from the old
3499 file made it into the new one.
</p></div>
3500 <div class=
"paragraph"><p>The index line includes the blob object names before and after the change.
3501 The
<mode
> is included if the file mode does not change; otherwise,
3502 separate lines indicate the old and the new mode.
</p></div>
3506 Pathnames with
"unusual" characters are quoted as explained for
3507 the configuration variable
<code>core.quotePath
</code> (see
3508 <a href=
"git-config.html">git-config(
1)
</a>).
3513 All the
<code>file1
</code> files in the output refer to files before the
3514 commit, and all the
<code>file2
</code> files refer to files after the commit.
3515 It is incorrect to apply each change to each file sequentially. For
3516 example, this patch will swap a and b:
3518 <div class=
"literalblock">
3519 <div class=
"content">
3520 <pre><code>diff --git a/a b/b
3525 rename to a
</code></pre>
3530 Hunk headers mention the name of the function to which the hunk
3531 applies. See
"Defining a custom hunk-header" in
3532 <a href=
"gitattributes.html">gitattributes(
5)
</a> for details of how to tailor this to
3540 <h2 id=
"_combined_diff_format">Combined diff format
</h2>
3541 <div class=
"sectionbody">
3542 <div class=
"paragraph"><p>Any diff-generating command can take the
<code>-c
</code> or
<code>--cc
</code> option to
3543 produce a
<em>combined diff
</em> when showing a merge. This is the default
3544 format when showing merges with
<a href=
"git-diff.html">git-diff(
1)
</a> or
3545 <a href=
"git-show.html">git-show(
1)
</a>. Note also that you can give suitable
3546 <code>--diff-merges
</code> option to any of these commands to force generation of
3547 diffs in a specific format.
</p></div>
3548 <div class=
"paragraph"><p>A
"combined diff" format looks like this:
</p></div>
3549 <div class=
"listingblock">
3550 <div class=
"content">
3551 <pre><code>diff --combined describe.c
3552 index fabadb8,cc95eb0.
.4866510
3555 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
3556 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
3559 - static void describe(char *arg)
3560 -static void describe(struct commit *cmit, int last_one)
3561 ++static void describe(char *arg, int last_one)
3563 + unsigned char sha1[
20];
3564 + struct commit *cmit;
3565 struct commit_list *list;
3566 static int initialized =
0;
3567 struct commit_name *n;
3569 + if (get_sha1(arg, sha1)
< 0)
3570 + usage(describe_usage);
3571 + cmit = lookup_commit_reference(sha1);
3573 + usage(describe_usage);
3577 for_each_ref(get_name);
</code></pre>
3579 <div class=
"olist arabic"><ol class=
"arabic">
3582 It is preceded by a
"git diff" header, that looks like
3583 this (when the
<code>-c
</code> option is used):
3585 <div class=
"literalblock">
3586 <div class=
"content">
3587 <pre><code>diff --combined file
</code></pre>
3589 <div class=
"paragraph"><p>or like this (when the
<code>--cc
</code> option is used):
</p></div>
3590 <div class=
"literalblock">
3591 <div class=
"content">
3592 <pre><code>diff --cc file
</code></pre>
3597 It is followed by one or more extended header lines
3598 (this example shows a merge with two parents):
3600 <div class=
"literalblock">
3601 <div class=
"content">
3602 <pre><code>index
<hash
>,
<hash
>..
<hash
>
3603 mode
<mode
>,
<mode
>..
<mode
>
3604 new file mode
<mode
>
3605 deleted file mode
<mode
>,
<mode
></code></pre>
3607 <div class=
"paragraph"><p>The
<code>mode
<mode
>,
<mode
>..
<mode
></code> line appears only if at least one of
3608 the
<mode
> is different from the rest. Extended headers with
3609 information about detected content movement (renames and
3610 copying detection) are designed to work with the diff of two
3611 <tree-ish
> and are not used by combined diff format.
</p></div>
3615 It is followed by a two-line from-file/to-file header:
3617 <div class=
"literalblock">
3618 <div class=
"content">
3619 <pre><code>--- a/file
3620 +++ b/file
</code></pre>
3622 <div class=
"paragraph"><p>Similar to the two-line header for the traditional
<em>unified
</em> diff
3623 format,
<code>/dev/null
</code> is used to signal created or deleted
3625 <div class=
"paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
3626 two-line from-file/to-file, you get an N+
1 line from-file/to-file header,
3627 where N is the number of parents in the merge commit:
</p></div>
3628 <div class=
"literalblock">
3629 <div class=
"content">
3630 <pre><code>--- a/file
3633 +++ b/file
</code></pre>
3635 <div class=
"paragraph"><p>This extended format can be useful if rename or copy detection is
3636 active, to allow you to see the original name of the file in different
3641 Chunk header format is modified to prevent people from
3642 accidentally feeding it to
<code>patch -p1
</code>. Combined diff format
3643 was created for review of merge commit changes, and was not
3644 meant to be applied. The change is similar to the change in the
3645 extended
<em>index
</em> header:
3647 <div class=
"literalblock">
3648 <div class=
"content">
3649 <pre><code>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</code></pre>
3651 <div class=
"paragraph"><p>There are (number of parents +
1)
<code>@
</code> characters in the chunk
3652 header for combined diff format.
</p></div>
3655 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
3656 files A and B with a single column that has
<code>-
</code> (minus
 — appears in A but removed in B),
<code>+
</code> (plus
 — missing in A but
3657 added to B), or
<code>" "</code> (space
 — unchanged) prefix, this format
3658 compares two or more files file1, file2,
… with one file X, and
3659 shows how X differs from each of fileN. One column for each of
3660 fileN is prepended to the output line to note how X
’s line is
3661 different from it.
</p></div>
3662 <div class=
"paragraph"><p>A
<code>-
</code> character in the column N means that the line appears in
3663 fileN but it does not appear in the result. A
<code>+
</code> character
3664 in the column N means that the line appears in the result,
3665 and fileN does not have that line (in other words, the line was
3666 added, from the point of view of that parent).
</p></div>
3667 <div class=
"paragraph"><p>In the above example output, the function signature was changed
3668 from both files (hence two
<code>-
</code> removals from both file1 and
3669 file2, plus
<code>++
</code> to mean one line that was added does not appear
3670 in either file1 or file2). Also, eight other lines are the same
3671 from file1 but do not appear in file2 (hence prefixed with
<code>+
</code>).
</p></div>
3672 <div class=
"paragraph"><p>When shown by
<code>git diff-tree -c
</code>, it compares the parents of a
3673 merge commit with the merge result (i.e. file1..fileN are the
3674 parents). When shown by
<code>git diff-files -c
</code>, it compares the
3675 two unresolved merge parents with the working tree file
3676 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
3677 "their version").
</p></div>
3681 <h2 id=
"_examples">EXAMPLES
</h2>
3682 <div class=
"sectionbody">
3683 <div class=
"dlist"><dl>
3684 <dt class=
"hdlist1">
3685 <code>git show v1.0
.0</code>
3689 Shows the tag
<code>v1.0
.0</code>, along with the object the tag
3693 <dt class=
"hdlist1">
3694 <code>git show v1.0
.0^{tree}
</code>
3698 Shows the tree pointed to by the tag
<code>v1.0
.0</code>.
3701 <dt class=
"hdlist1">
3702 <code>git show -s --format=%s v1.0
.0^{commit}
</code>
3706 Shows the subject of the commit pointed to by the
3707 tag
<code>v1.0
.0</code>.
3710 <dt class=
"hdlist1">
3711 <code>git show next~
10:Documentation/README
</code>
3715 Shows the contents of the file
<code>Documentation/README
</code> as
3716 they were current in the
10th last commit of the branch
3720 <dt class=
"hdlist1">
3721 <code>git show master:Makefile master:t/Makefile
</code>
3725 Concatenates the contents of said Makefiles in the head
3726 of the branch
<code>master
</code>.
3733 <h2 id=
"_discussion">DISCUSSION
</h2>
3734 <div class=
"sectionbody">
3735 <div class=
"paragraph"><p>Git is to some extent character encoding agnostic.
</p></div>
3736 <div class=
"ulist"><ul>
3739 The contents of the blob objects are uninterpreted sequences
3740 of bytes. There is no encoding translation at the core
3746 Path names are encoded in UTF-
8 normalization form C. This
3747 applies to tree objects, the index file, ref names, as well as
3748 path names in command line arguments, environment variables
3749 and config files (
<code>.git/config
</code> (see
<a href=
"git-config.html">git-config(
1)
</a>),
3750 <a href=
"gitignore.html">gitignore(
5)
</a>,
<a href=
"gitattributes.html">gitattributes(
5)
</a> and
3751 <a href=
"gitmodules.html">gitmodules(
5)
</a>).
3753 <div class=
"paragraph"><p>Note that Git at the core level treats path names simply as
3754 sequences of non-NUL bytes, there are no path name encoding
3755 conversions (except on Mac and Windows). Therefore, using
3756 non-ASCII path names will mostly work even on platforms and file
3757 systems that use legacy extended ASCII encodings. However,
3758 repositories created on such systems will not work properly on
3759 UTF-
8-based systems (e.g. Linux, Mac, Windows) and vice versa.
3760 Additionally, many Git-based tools simply assume path names to
3761 be UTF-
8 and will fail to display other encodings correctly.
</p></div>
3765 Commit log messages are typically encoded in UTF-
8, but other
3766 extended ASCII encodings are also supported. This includes
3767 ISO-
8859-x, CP125x and many others, but
<em>not
</em> UTF-
16/
32,
3768 EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5,
3773 <div class=
"paragraph"><p>Although we encourage that the commit log messages are encoded
3774 in UTF-
8, both the core and Git Porcelain are designed not to
3775 force UTF-
8 on projects. If all participants of a particular
3776 project find it more convenient to use legacy encodings, Git
3777 does not forbid it. However, there are a few things to keep in
3779 <div class=
"olist arabic"><ol class=
"arabic">
3782 <em>git commit
</em> and
<em>git commit-tree
</em> issue
3783 a warning if the commit log message given to it does not look
3784 like a valid UTF-
8 string, unless you explicitly say your
3785 project uses a legacy encoding. The way to say this is to
3786 have
<code>i18n.commitEncoding
</code> in
<code>.git/config
</code> file, like this:
3788 <div class=
"listingblock">
3789 <div class=
"content">
3791 commitEncoding = ISO-
8859-
1</code></pre>
3793 <div class=
"paragraph"><p>Commit objects created with the above setting record the value
3794 of
<code>i18n.commitEncoding
</code> in their
<code>encoding
</code> header. This is to
3795 help other people who look at them later. Lack of this header
3796 implies that the commit log message is encoded in UTF-
8.
</p></div>
3800 <em>git log
</em>,
<em>git show
</em>,
<em>git blame
</em> and friends look at the
3801 <code>encoding
</code> header of a commit object, and try to re-code the
3802 log message into UTF-
8 unless otherwise specified. You can
3803 specify the desired output encoding with
3804 <code>i18n.logOutputEncoding
</code> in
<code>.git/config
</code> file, like this:
3806 <div class=
"listingblock">
3807 <div class=
"content">
3809 logOutputEncoding = ISO-
8859-
1</code></pre>
3811 <div class=
"paragraph"><p>If you do not have this configuration variable, the value of
3812 <code>i18n.commitEncoding
</code> is used instead.
</p></div>
3815 <div class=
"paragraph"><p>Note that we deliberately chose not to re-code the commit log
3816 message when a commit is made to force UTF-
8 at the commit
3817 object level, because re-coding to UTF-
8 is not necessarily a
3818 reversible operation.
</p></div>
3822 <h2 id=
"_git">GIT
</h2>
3823 <div class=
"sectionbody">
3824 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
3828 <div id=
"footnotes"><hr /></div>
3830 <div id=
"footer-text">
3832 2023-
10-
23 14:
43:
46 PDT