Autogenerated HTML docs for v2.45.2-606-g900514
[git-htmldocs.git] / git-diff-index.html
blobea32fe01e99339e1d991ed420d5af4709cb2257a
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">
5 <head>
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-diff-index(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.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 {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
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; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
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 {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
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; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
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;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
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 {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: 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;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
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
552 * Version: 0.4
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 */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
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
586 // browsers).
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);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
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");
631 div.appendChild(a);
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.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
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");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!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];
678 spans[i].innerHTML =
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;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
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.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-diff-index(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-diff-index -
743 Compare a tree to the working tree or index
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git diff-index</em> [-m] [--cached] [--merge-base] [&lt;common-diff-options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</pre>
753 <div class="attribution">
754 </div></div>
755 </div>
756 </div>
757 <div class="sect1">
758 <h2 id="_description">DESCRIPTION</h2>
759 <div class="sectionbody">
760 <div class="paragraph"><p>Compare the content and mode of the blobs found in a tree object
761 with the corresponding tracked files in the working tree, or with the
762 corresponding paths in the index. When &lt;path&gt; arguments are present,
763 compare only paths matching those patterns. Otherwise all tracked
764 files are compared.</p></div>
765 </div>
766 </div>
767 <div class="sect1">
768 <h2 id="_options">OPTIONS</h2>
769 <div class="sectionbody">
770 <div class="dlist"><dl>
771 <dt class="hdlist1">
773 </dt>
774 <dt class="hdlist1">
776 </dt>
777 <dt class="hdlist1">
778 --patch
779 </dt>
780 <dd>
782 Generate patch (see <a href="#generate_patch_text_with_p">[generate_patch_text_with_p]</a>).
783 </p>
784 </dd>
785 <dt class="hdlist1">
787 </dt>
788 <dt class="hdlist1">
789 --no-patch
790 </dt>
791 <dd>
793 Suppress all output from the diff machinery. Useful for
794 commands like <code>git show</code> that show the patch by default to
795 squelch their output, or to cancel the effect of options like
796 <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.
797 </p>
798 </dd>
799 <dt class="hdlist1">
800 -U&lt;n&gt;
801 </dt>
802 <dt class="hdlist1">
803 --unified=&lt;n&gt;
804 </dt>
805 <dd>
807 Generate diffs with &lt;n&gt; lines of context instead of
808 the usual three.
809 Implies <code>--patch</code>.
810 </p>
811 </dd>
812 <dt class="hdlist1">
813 --output=&lt;file&gt;
814 </dt>
815 <dd>
817 Output to a specific file instead of stdout.
818 </p>
819 </dd>
820 <dt class="hdlist1">
821 --output-indicator-new=&lt;char&gt;
822 </dt>
823 <dt class="hdlist1">
824 --output-indicator-old=&lt;char&gt;
825 </dt>
826 <dt class="hdlist1">
827 --output-indicator-context=&lt;char&gt;
828 </dt>
829 <dd>
831 Specify the character used to indicate new, old or context
832 lines in the generated patch. Normally they are <em>+</em>, <em>-</em> and
833 ' ' respectively.
834 </p>
835 </dd>
836 <dt class="hdlist1">
837 --raw
838 </dt>
839 <dd>
841 Generate the diff in raw format.
842 This is the default.
843 </p>
844 </dd>
845 <dt class="hdlist1">
846 --patch-with-raw
847 </dt>
848 <dd>
850 Synonym for <code>-p --raw</code>.
851 </p>
852 </dd>
853 <dt class="hdlist1">
854 --indent-heuristic
855 </dt>
856 <dd>
858 Enable the heuristic that shifts diff hunk boundaries to make patches
859 easier to read. This is the default.
860 </p>
861 </dd>
862 <dt class="hdlist1">
863 --no-indent-heuristic
864 </dt>
865 <dd>
867 Disable the indent heuristic.
868 </p>
869 </dd>
870 <dt class="hdlist1">
871 --minimal
872 </dt>
873 <dd>
875 Spend extra time to make sure the smallest possible
876 diff is produced.
877 </p>
878 </dd>
879 <dt class="hdlist1">
880 --patience
881 </dt>
882 <dd>
884 Generate a diff using the "patience diff" algorithm.
885 </p>
886 </dd>
887 <dt class="hdlist1">
888 --histogram
889 </dt>
890 <dd>
892 Generate a diff using the "histogram diff" algorithm.
893 </p>
894 </dd>
895 <dt class="hdlist1">
896 --anchored=&lt;text&gt;
897 </dt>
898 <dd>
900 Generate a diff using the "anchored diff" algorithm.
901 </p>
902 <div class="paragraph"><p>This option may be specified more than once.</p></div>
903 <div class="paragraph"><p>If a line exists in both the source and destination, exists only once,
904 and starts with this text, this algorithm attempts to prevent it from
905 appearing as a deletion or addition in the output. It uses the "patience
906 diff" algorithm internally.</p></div>
907 </dd>
908 <dt class="hdlist1">
909 --diff-algorithm={patience|minimal|histogram|myers}
910 </dt>
911 <dd>
913 Choose a diff algorithm. The variants are as follows:
914 </p>
915 <div class="openblock">
916 <div class="content">
917 <div class="dlist"><dl>
918 <dt class="hdlist1">
919 <code>default</code>, <code>myers</code>
920 </dt>
921 <dd>
923 The basic greedy diff algorithm. Currently, this is the default.
924 </p>
925 </dd>
926 <dt class="hdlist1">
927 <code>minimal</code>
928 </dt>
929 <dd>
931 Spend extra time to make sure the smallest possible diff is
932 produced.
933 </p>
934 </dd>
935 <dt class="hdlist1">
936 <code>patience</code>
937 </dt>
938 <dd>
940 Use "patience diff" algorithm when generating patches.
941 </p>
942 </dd>
943 <dt class="hdlist1">
944 <code>histogram</code>
945 </dt>
946 <dd>
948 This algorithm extends the patience algorithm to "support
949 low-occurrence common elements".
950 </p>
951 </dd>
952 </dl></div>
953 </div></div>
954 <div class="paragraph"><p>For instance, if you configured the <code>diff.algorithm</code> variable to a
955 non-default value and want to use the default one, then you
956 have to use <code>--diff-algorithm=default</code> option.</p></div>
957 </dd>
958 <dt class="hdlist1">
959 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
960 </dt>
961 <dd>
963 Generate a diffstat. By default, as much space as necessary
964 will be used for the filename part, and the rest for the graph
965 part. Maximum width defaults to terminal width, or 80 columns
966 if not connected to a terminal, and can be overridden by
967 <code>&lt;width&gt;</code>. The width of the filename part can be limited by
968 giving another width <code>&lt;name-width&gt;</code> after a comma or by setting
969 <code>diff.statNameWidth=&lt;width&gt;</code>. The width of the graph part can be
970 limited by using <code>--stat-graph-width=&lt;width&gt;</code> or by setting
971 <code>diff.statGraphWidth=&lt;width&gt;</code>. Using <code>--stat</code> or
972 <code>--stat-graph-width</code> affects all commands generating a stat graph,
973 while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code>
974 does not affect <code>git format-patch</code>.
975 By giving a third parameter <code>&lt;count&gt;</code>, you can limit the output to
976 the first <code>&lt;count&gt;</code> lines, followed by <code>...</code> if there are more.
977 </p>
978 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=&lt;width&gt;</code>,
979 <code>--stat-name-width=&lt;name-width&gt;</code> and <code>--stat-count=&lt;count&gt;</code>.</p></div>
980 </dd>
981 <dt class="hdlist1">
982 --compact-summary
983 </dt>
984 <dd>
986 Output a condensed summary of extended header information such
987 as file creations or deletions ("new" or "gone", optionally "+l"
988 if it&#8217;s a symlink) and mode changes ("+x" or "-x" for adding
989 or removing executable bit respectively) in diffstat. The
990 information is put between the filename part and the graph
991 part. Implies <code>--stat</code>.
992 </p>
993 </dd>
994 <dt class="hdlist1">
995 --numstat
996 </dt>
997 <dd>
999 Similar to <code>--stat</code>, but shows number of added and
1000 deleted lines in decimal notation and pathname without
1001 abbreviation, to make it more machine friendly. For
1002 binary files, outputs two <code>-</code> instead of saying
1003 <code>0 0</code>.
1004 </p>
1005 </dd>
1006 <dt class="hdlist1">
1007 --shortstat
1008 </dt>
1009 <dd>
1011 Output only the last line of the <code>--stat</code> format containing total
1012 number of modified files, as well as number of added and deleted
1013 lines.
1014 </p>
1015 </dd>
1016 <dt class="hdlist1">
1017 -X[&lt;param1,param2,&#8230;&gt;]
1018 </dt>
1019 <dt class="hdlist1">
1020 --dirstat[=&lt;param1,param2,&#8230;&gt;]
1021 </dt>
1022 <dd>
1024 Output the distribution of relative amount of changes for each
1025 sub-directory. The behavior of <code>--dirstat</code> can be customized by
1026 passing it a comma separated list of parameters.
1027 The defaults are controlled by the <code>diff.dirstat</code> configuration
1028 variable (see <a href="git-config.html">git-config(1)</a>).
1029 The following parameters are available:
1030 </p>
1031 <div class="openblock">
1032 <div class="content">
1033 <div class="dlist"><dl>
1034 <dt class="hdlist1">
1035 <code>changes</code>
1036 </dt>
1037 <dd>
1039 Compute the dirstat numbers by counting the lines that have been
1040 removed from the source, or added to the destination. This ignores
1041 the amount of pure code movements within a file. In other words,
1042 rearranging lines in a file is not counted as much as other changes.
1043 This is the default behavior when no parameter is given.
1044 </p>
1045 </dd>
1046 <dt class="hdlist1">
1047 <code>lines</code>
1048 </dt>
1049 <dd>
1051 Compute the dirstat numbers by doing the regular line-based diff
1052 analysis, and summing the removed/added line counts. (For binary
1053 files, count 64-byte chunks instead, since binary files have no
1054 natural concept of lines). This is a more expensive <code>--dirstat</code>
1055 behavior than the <code>changes</code> behavior, but it does count rearranged
1056 lines within a file as much as other changes. The resulting output
1057 is consistent with what you get from the other <code>--*stat</code> options.
1058 </p>
1059 </dd>
1060 <dt class="hdlist1">
1061 <code>files</code>
1062 </dt>
1063 <dd>
1065 Compute the dirstat numbers by counting the number of files changed.
1066 Each changed file counts equally in the dirstat analysis. This is
1067 the computationally cheapest <code>--dirstat</code> behavior, since it does
1068 not have to look at the file contents at all.
1069 </p>
1070 </dd>
1071 <dt class="hdlist1">
1072 <code>cumulative</code>
1073 </dt>
1074 <dd>
1076 Count changes in a child directory for the parent directory as well.
1077 Note that when using <code>cumulative</code>, the sum of the percentages
1078 reported may exceed 100%. The default (non-cumulative) behavior can
1079 be specified with the <code>noncumulative</code> parameter.
1080 </p>
1081 </dd>
1082 <dt class="hdlist1">
1083 &lt;limit&gt;
1084 </dt>
1085 <dd>
1087 An integer parameter specifies a cut-off percent (3% by default).
1088 Directories contributing less than this percentage of the changes
1089 are not shown in the output.
1090 </p>
1091 </dd>
1092 </dl></div>
1093 </div></div>
1094 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1095 directories with less than 10% of the total amount of changed files,
1096 and accumulating child directory counts in the parent directories:
1097 <code>--dirstat=files,10,cumulative</code>.</p></div>
1098 </dd>
1099 <dt class="hdlist1">
1100 --cumulative
1101 </dt>
1102 <dd>
1104 Synonym for --dirstat=cumulative
1105 </p>
1106 </dd>
1107 <dt class="hdlist1">
1108 --dirstat-by-file[=&lt;param1,param2&gt;&#8230;]
1109 </dt>
1110 <dd>
1112 Synonym for --dirstat=files,&lt;param1&gt;,&lt;param2&gt;&#8230;
1113 </p>
1114 </dd>
1115 <dt class="hdlist1">
1116 --summary
1117 </dt>
1118 <dd>
1120 Output a condensed summary of extended header information
1121 such as creations, renames and mode changes.
1122 </p>
1123 </dd>
1124 <dt class="hdlist1">
1125 --patch-with-stat
1126 </dt>
1127 <dd>
1129 Synonym for <code>-p --stat</code>.
1130 </p>
1131 </dd>
1132 <dt class="hdlist1">
1134 </dt>
1135 <dd>
1137 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1138 given, do not munge pathnames and use NULs as output field terminators.
1139 </p>
1140 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1141 explained for the configuration variable <code>core.quotePath</code> (see
1142 <a href="git-config.html">git-config(1)</a>).</p></div>
1143 </dd>
1144 <dt class="hdlist1">
1145 --name-only
1146 </dt>
1147 <dd>
1149 Show only the name of each changed file in the post-image tree.
1150 The file names are often encoded in UTF-8.
1151 For more information see the discussion about encoding in the <a href="git-log.html">git-log(1)</a>
1152 manual page.
1153 </p>
1154 </dd>
1155 <dt class="hdlist1">
1156 --name-status
1157 </dt>
1158 <dd>
1160 Show only the name(s) and status of each changed file. See the description
1161 of the <code>--diff-filter</code> option on what the status letters mean.
1162 Just like <code>--name-only</code> the file names are often encoded in UTF-8.
1163 </p>
1164 </dd>
1165 <dt class="hdlist1">
1166 --submodule[=&lt;format&gt;]
1167 </dt>
1168 <dd>
1170 Specify how differences in submodules are shown. When specifying
1171 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1172 shows the names of the commits at the beginning and end of the range.
1173 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1174 format is used. This format lists the commits in the range like
1175 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1176 is specified, the <em>diff</em> format is used. This format shows an
1177 inline diff of the changes in the submodule contents between the
1178 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1179 if the config option is unset.
1180 </p>
1181 </dd>
1182 <dt class="hdlist1">
1183 --color[=&lt;when&gt;]
1184 </dt>
1185 <dd>
1187 Show colored diff.
1188 <code>--color</code> (i.e. without <em>=&lt;when&gt;</em>) is the same as <code>--color=always</code>.
1189 <em>&lt;when&gt;</em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1190 </p>
1191 </dd>
1192 <dt class="hdlist1">
1193 --no-color
1194 </dt>
1195 <dd>
1197 Turn off colored diff.
1198 It is the same as <code>--color=never</code>.
1199 </p>
1200 </dd>
1201 <dt class="hdlist1">
1202 --color-moved[=&lt;mode&gt;]
1203 </dt>
1204 <dd>
1206 Moved lines of code are colored differently.
1207 The &lt;mode&gt; defaults to <em>no</em> if the option is not given
1208 and to <em>zebra</em> if the option with no mode is given.
1209 The mode must be one of:
1210 </p>
1211 <div class="openblock">
1212 <div class="content">
1213 <div class="dlist"><dl>
1214 <dt class="hdlist1">
1216 </dt>
1217 <dd>
1219 Moved lines are not highlighted.
1220 </p>
1221 </dd>
1222 <dt class="hdlist1">
1223 default
1224 </dt>
1225 <dd>
1227 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1228 in the future.
1229 </p>
1230 </dd>
1231 <dt class="hdlist1">
1232 plain
1233 </dt>
1234 <dd>
1236 Any line that is added in one location and was removed
1237 in another location will be colored with <em>color.diff.newMoved</em>.
1238 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1239 that are added somewhere else in the diff. This mode picks up any
1240 moved line, but it is not very useful in a review to determine
1241 if a block of code was moved without permutation.
1242 </p>
1243 </dd>
1244 <dt class="hdlist1">
1245 blocks
1246 </dt>
1247 <dd>
1249 Blocks of moved text of at least 20 alphanumeric characters
1250 are detected greedily. The detected blocks are
1251 painted using either the <em>color.diff.{old,new}Moved</em> color.
1252 Adjacent blocks cannot be told apart.
1253 </p>
1254 </dd>
1255 <dt class="hdlist1">
1256 zebra
1257 </dt>
1258 <dd>
1260 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1261 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1262 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1263 the two colors indicates that a new block was detected.
1264 </p>
1265 </dd>
1266 <dt class="hdlist1">
1267 dimmed-zebra
1268 </dt>
1269 <dd>
1271 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1272 of moved code is performed. The bordering lines of two adjacent
1273 blocks are considered interesting, the rest is uninteresting.
1274 <code>dimmed_zebra</code> is a deprecated synonym.
1275 </p>
1276 </dd>
1277 </dl></div>
1278 </div></div>
1279 </dd>
1280 <dt class="hdlist1">
1281 --no-color-moved
1282 </dt>
1283 <dd>
1285 Turn off move detection. This can be used to override configuration
1286 settings. It is the same as <code>--color-moved=no</code>.
1287 </p>
1288 </dd>
1289 <dt class="hdlist1">
1290 --color-moved-ws=&lt;modes&gt;
1291 </dt>
1292 <dd>
1294 This configures how whitespace is ignored when performing the
1295 move detection for <code>--color-moved</code>.
1296 These modes can be given as a comma separated list:
1297 </p>
1298 <div class="openblock">
1299 <div class="content">
1300 <div class="dlist"><dl>
1301 <dt class="hdlist1">
1303 </dt>
1304 <dd>
1306 Do not ignore whitespace when performing move detection.
1307 </p>
1308 </dd>
1309 <dt class="hdlist1">
1310 ignore-space-at-eol
1311 </dt>
1312 <dd>
1314 Ignore changes in whitespace at EOL.
1315 </p>
1316 </dd>
1317 <dt class="hdlist1">
1318 ignore-space-change
1319 </dt>
1320 <dd>
1322 Ignore changes in amount of whitespace. This ignores whitespace
1323 at line end, and considers all other sequences of one or
1324 more whitespace characters to be equivalent.
1325 </p>
1326 </dd>
1327 <dt class="hdlist1">
1328 ignore-all-space
1329 </dt>
1330 <dd>
1332 Ignore whitespace when comparing lines. This ignores differences
1333 even if one line has whitespace where the other line has none.
1334 </p>
1335 </dd>
1336 <dt class="hdlist1">
1337 allow-indentation-change
1338 </dt>
1339 <dd>
1341 Initially ignore any whitespace in the move detection, then
1342 group the moved code blocks only into a block if the change in
1343 whitespace is the same per line. This is incompatible with the
1344 other modes.
1345 </p>
1346 </dd>
1347 </dl></div>
1348 </div></div>
1349 </dd>
1350 <dt class="hdlist1">
1351 --no-color-moved-ws
1352 </dt>
1353 <dd>
1355 Do not ignore whitespace when performing move detection. This can be
1356 used to override configuration settings. It is the same as
1357 <code>--color-moved-ws=no</code>.
1358 </p>
1359 </dd>
1360 <dt class="hdlist1">
1361 --word-diff[=&lt;mode&gt;]
1362 </dt>
1363 <dd>
1365 Show a word diff, using the &lt;mode&gt; to delimit changed words.
1366 By default, words are delimited by whitespace; see
1367 <code>--word-diff-regex</code> below. The &lt;mode&gt; defaults to <em>plain</em>, and
1368 must be one of:
1369 </p>
1370 <div class="openblock">
1371 <div class="content">
1372 <div class="dlist"><dl>
1373 <dt class="hdlist1">
1374 color
1375 </dt>
1376 <dd>
1378 Highlight changed words using only colors. Implies <code>--color</code>.
1379 </p>
1380 </dd>
1381 <dt class="hdlist1">
1382 plain
1383 </dt>
1384 <dd>
1386 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1387 attempts to escape the delimiters if they appear in the input,
1388 so the output may be ambiguous.
1389 </p>
1390 </dd>
1391 <dt class="hdlist1">
1392 porcelain
1393 </dt>
1394 <dd>
1396 Use a special line-based format intended for script
1397 consumption. Added/removed/unchanged runs are printed in the
1398 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1399 character at the beginning of the line and extending to the
1400 end of the line. Newlines in the input are represented by a
1401 tilde <code>~</code> on a line of its own.
1402 </p>
1403 </dd>
1404 <dt class="hdlist1">
1405 none
1406 </dt>
1407 <dd>
1409 Disable word diff again.
1410 </p>
1411 </dd>
1412 </dl></div>
1413 </div></div>
1414 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1415 highlight the changed parts in all modes if enabled.</p></div>
1416 </dd>
1417 <dt class="hdlist1">
1418 --word-diff-regex=&lt;regex&gt;
1419 </dt>
1420 <dd>
1422 Use &lt;regex&gt; to decide what a word is, instead of considering
1423 runs of non-whitespace to be a word. Also implies
1424 <code>--word-diff</code> unless it was already enabled.
1425 </p>
1426 <div class="paragraph"><p>Every non-overlapping match of the
1427 &lt;regex&gt; is considered a word. Anything between these matches is
1428 considered whitespace and ignored(!) for the purposes of finding
1429 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1430 expression to make sure that it matches all non-whitespace characters.
1431 A match that contains a newline is silently truncated(!) at the
1432 newline.</p></div>
1433 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1434 and, correspondingly, show differences character by character.</p></div>
1435 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1436 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1437 overrides any diff driver or configuration setting. Diff drivers
1438 override configuration settings.</p></div>
1439 </dd>
1440 <dt class="hdlist1">
1441 --color-words[=&lt;regex&gt;]
1442 </dt>
1443 <dd>
1445 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1446 specified) <code>--word-diff-regex=&lt;regex&gt;</code>.
1447 </p>
1448 </dd>
1449 <dt class="hdlist1">
1450 --no-renames
1451 </dt>
1452 <dd>
1454 Turn off rename detection, even when the configuration
1455 file gives the default to do so.
1456 </p>
1457 </dd>
1458 <dt class="hdlist1">
1459 --[no-]rename-empty
1460 </dt>
1461 <dd>
1463 Whether to use empty blobs as rename source.
1464 </p>
1465 </dd>
1466 <dt class="hdlist1">
1467 --check
1468 </dt>
1469 <dd>
1471 Warn if changes introduce conflict markers or whitespace errors.
1472 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1473 configuration. By default, trailing whitespaces (including
1474 lines that consist solely of whitespaces) and a space character
1475 that is immediately followed by a tab character inside the
1476 initial indent of the line are considered whitespace errors.
1477 Exits with non-zero status if problems are found. Not compatible
1478 with --exit-code.
1479 </p>
1480 </dd>
1481 <dt class="hdlist1">
1482 --ws-error-highlight=&lt;kind&gt;
1483 </dt>
1484 <dd>
1486 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1487 lines of the diff. Multiple values are separated by comma,
1488 <code>none</code> resets previous values, <code>default</code> reset the list to
1489 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1490 this option is not given, and the configuration variable
1491 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1492 <code>new</code> lines are highlighted. The whitespace errors are colored
1493 with <code>color.diff.whitespace</code>.
1494 </p>
1495 </dd>
1496 <dt class="hdlist1">
1497 --full-index
1498 </dt>
1499 <dd>
1501 Instead of the first handful of characters, show the full
1502 pre- and post-image blob object names on the "index"
1503 line when generating patch format output.
1504 </p>
1505 </dd>
1506 <dt class="hdlist1">
1507 --binary
1508 </dt>
1509 <dd>
1511 In addition to <code>--full-index</code>, output a binary diff that
1512 can be applied with <code>git-apply</code>.
1513 Implies <code>--patch</code>.
1514 </p>
1515 </dd>
1516 <dt class="hdlist1">
1517 --abbrev[=&lt;n&gt;]
1518 </dt>
1519 <dd>
1521 Instead of showing the full 40-byte hexadecimal object
1522 name in diff-raw format output and diff-tree header
1523 lines, show the shortest prefix that is at least <em>&lt;n&gt;</em>
1524 hexdigits long that uniquely refers the object.
1525 In diff-patch output format, <code>--full-index</code> takes higher
1526 precedence, i.e. if <code>--full-index</code> is specified, full blob
1527 names will be shown regardless of <code>--abbrev</code>.
1528 Non default number of digits can be specified with <code>--abbrev=&lt;n&gt;</code>.
1529 </p>
1530 </dd>
1531 <dt class="hdlist1">
1532 -B[&lt;n&gt;][/&lt;m&gt;]
1533 </dt>
1534 <dt class="hdlist1">
1535 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1536 </dt>
1537 <dd>
1539 Break complete rewrite changes into pairs of delete and
1540 create. This serves two purposes:
1541 </p>
1542 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1543 not as a series of deletion and insertion mixed together with a very
1544 few lines that happen to match textually as the context, but as a
1545 single deletion of everything old followed by a single insertion of
1546 everything new, and the number <code>m</code> controls this aspect of the -B
1547 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1548 original should remain in the result for Git to consider it a total
1549 rewrite (i.e. otherwise the resulting patch will be a series of
1550 deletion and insertion mixed together with context lines).</p></div>
1551 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1552 source of a rename (usually -M only considers a file that disappeared
1553 as the source of a rename), and the number <code>n</code> controls this aspect of
1554 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1555 addition and deletion compared to 20% or more of the file&#8217;s size are
1556 eligible for being picked up as a possible source of a rename to
1557 another file.</p></div>
1558 </dd>
1559 <dt class="hdlist1">
1560 -M[&lt;n&gt;]
1561 </dt>
1562 <dt class="hdlist1">
1563 --find-renames[=&lt;n&gt;]
1564 </dt>
1565 <dd>
1567 Detect renames.
1568 If <code>n</code> is specified, it is a threshold on the similarity
1569 index (i.e. amount of addition/deletions compared to the
1570 file&#8217;s size). For example, <code>-M90%</code> means Git should consider a
1571 delete/add pair to be a rename if more than 90% of the file
1572 hasn&#8217;t changed. Without a <code>%</code> sign, the number is to be read as
1573 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1574 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1575 the same as <code>-M5%</code>. To limit detection to exact renames, use
1576 <code>-M100%</code>. The default similarity index is 50%.
1577 </p>
1578 </dd>
1579 <dt class="hdlist1">
1580 -C[&lt;n&gt;]
1581 </dt>
1582 <dt class="hdlist1">
1583 --find-copies[=&lt;n&gt;]
1584 </dt>
1585 <dd>
1587 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1588 If <code>n</code> is specified, it has the same meaning as for <code>-M&lt;n&gt;</code>.
1589 </p>
1590 </dd>
1591 <dt class="hdlist1">
1592 --find-copies-harder
1593 </dt>
1594 <dd>
1596 For performance reasons, by default, <code>-C</code> option finds copies only
1597 if the original file of the copy was modified in the same
1598 changeset. This flag makes the command
1599 inspect unmodified files as candidates for the source of
1600 copy. This is a very expensive operation for large
1601 projects, so use it with caution. Giving more than one
1602 <code>-C</code> option has the same effect.
1603 </p>
1604 </dd>
1605 <dt class="hdlist1">
1607 </dt>
1608 <dt class="hdlist1">
1609 --irreversible-delete
1610 </dt>
1611 <dd>
1613 Omit the preimage for deletes, i.e. print only the header but not
1614 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1615 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1616 solely for people who want to just concentrate on reviewing the
1617 text after the change. In addition, the output obviously lacks
1618 enough information to apply such a patch in reverse, even manually,
1619 hence the name of the option.
1620 </p>
1621 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1622 of a delete/create pair.</p></div>
1623 </dd>
1624 <dt class="hdlist1">
1625 -l&lt;num&gt;
1626 </dt>
1627 <dd>
1629 The <code>-M</code> and <code>-C</code> options involve some preliminary steps that
1630 can detect subsets of renames/copies cheaply, followed by an
1631 exhaustive fallback portion that compares all remaining
1632 unpaired destinations to all relevant sources. (For renames,
1633 only remaining unpaired sources are relevant; for copies, all
1634 original sources are relevant.) For N sources and
1635 destinations, this exhaustive check is O(N^2). This option
1636 prevents the exhaustive portion of rename/copy detection from
1637 running if the number of source/destination files involved
1638 exceeds the specified number. Defaults to diff.renameLimit.
1639 Note that a value of 0 is treated as unlimited.
1640 </p>
1641 </dd>
1642 <dt class="hdlist1">
1643 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1644 </dt>
1645 <dd>
1647 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1648 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1649 type (i.e. regular file, symlink, submodule, &#8230;) changed (<code>T</code>),
1650 are Unmerged (<code>U</code>), are
1651 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1652 Any combination of the filter characters (including none) can be used.
1653 When <code>*</code> (All-or-none) is added to the combination, all
1654 paths are selected if there is any file that matches
1655 other criteria in the comparison; if there is no file
1656 that matches other criteria, nothing is selected.
1657 </p>
1658 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1659 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1660 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1661 renamed entries cannot appear if detection for those types is disabled.</p></div>
1662 </dd>
1663 <dt class="hdlist1">
1664 -S&lt;string&gt;
1665 </dt>
1666 <dd>
1668 Look for differences that change the number of occurrences of
1669 the specified string (i.e. addition/deletion) in a file.
1670 Intended for the scripter&#8217;s use.
1671 </p>
1672 <div class="paragraph"><p>It is useful when you&#8217;re looking for an exact block of code (like a
1673 struct), and want to know the history of that block since it first
1674 came into being: use the feature iteratively to feed the interesting
1675 block in the preimage back into <code>-S</code>, and keep going until you get the
1676 very first version of the block.</p></div>
1677 <div class="paragraph"><p>Binary files are searched as well.</p></div>
1678 </dd>
1679 <dt class="hdlist1">
1680 -G&lt;regex&gt;
1681 </dt>
1682 <dd>
1684 Look for differences whose patch text contains added/removed
1685 lines that match &lt;regex&gt;.
1686 </p>
1687 <div class="paragraph"><p>To illustrate the difference between <code>-S&lt;regex&gt; --pickaxe-regex</code> and
1688 <code>-G&lt;regex&gt;</code>, consider a commit with the following diff in the same
1689 file:</p></div>
1690 <div class="listingblock">
1691 <div class="content">
1692 <pre><code>+ return frotz(nitfol, two-&gt;ptr, 1, 0);
1694 - hit = frotz(nitfol, mf2.ptr, 1, 0);</code></pre>
1695 </div></div>
1696 <div class="paragraph"><p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log
1697 -S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of
1698 occurrences of that string did not change).</p></div>
1699 <div class="paragraph"><p>Unless <code>--text</code> is supplied patches of binary files without a textconv
1700 filter will be ignored.</p></div>
1701 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1702 information.</p></div>
1703 </dd>
1704 <dt class="hdlist1">
1705 --find-object=&lt;object-id&gt;
1706 </dt>
1707 <dd>
1709 Look for differences that change the number of occurrences of
1710 the specified object. Similar to <code>-S</code>, just the argument is different
1711 in that it doesn&#8217;t search for a specific string but for a specific
1712 object id.
1713 </p>
1714 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1715 <code>git-log</code> to also find trees.</p></div>
1716 </dd>
1717 <dt class="hdlist1">
1718 --pickaxe-all
1719 </dt>
1720 <dd>
1722 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1723 changeset, not just the files that contain the change
1724 in &lt;string&gt;.
1725 </p>
1726 </dd>
1727 <dt class="hdlist1">
1728 --pickaxe-regex
1729 </dt>
1730 <dd>
1732 Treat the &lt;string&gt; given to <code>-S</code> as an extended POSIX regular
1733 expression to match.
1734 </p>
1735 </dd>
1736 <dt class="hdlist1">
1737 -O&lt;orderfile&gt;
1738 </dt>
1739 <dd>
1741 Control the order in which files appear in the output.
1742 This overrides the <code>diff.orderFile</code> configuration variable
1743 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1744 use <code>-O/dev/null</code>.
1745 </p>
1746 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1747 &lt;orderfile&gt;.
1748 All files with pathnames that match the first pattern are output
1749 first, all files with pathnames that match the second pattern (but not
1750 the first) are output next, and so on.
1751 All files with pathnames that do not match any pattern are output
1752 last, as if there was an implicit match-all pattern at the end of the
1753 file.
1754 If multiple pathnames have the same rank (they match the same pattern
1755 but no earlier patterns), their output order relative to each other is
1756 the normal order.</p></div>
1757 <div class="paragraph"><p>&lt;orderfile&gt; is parsed as follows:</p></div>
1758 <div class="openblock">
1759 <div class="content">
1760 <div class="ulist"><ul>
1761 <li>
1763 Blank lines are ignored, so they can be used as separators for
1764 readability.
1765 </p>
1766 </li>
1767 <li>
1769 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1770 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1771 pattern if it starts with a hash.
1772 </p>
1773 </li>
1774 <li>
1776 Each other line contains a single pattern.
1777 </p>
1778 </li>
1779 </ul></div>
1780 </div></div>
1781 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1782 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1783 matches a pattern if removing any number of the final pathname
1784 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1785 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1786 </dd>
1787 <dt class="hdlist1">
1788 --skip-to=&lt;file&gt;
1789 </dt>
1790 <dt class="hdlist1">
1791 --rotate-to=&lt;file&gt;
1792 </dt>
1793 <dd>
1795 Discard the files before the named &lt;file&gt; from the output
1796 (i.e. <em>skip to</em>), or move them to the end of the output
1797 (i.e. <em>rotate to</em>). These options were invented primarily for the use
1798 of the <code>git difftool</code> command, and may not be very useful
1799 otherwise.
1800 </p>
1801 </dd>
1802 <dt class="hdlist1">
1804 </dt>
1805 <dd>
1807 Swap two inputs; that is, show differences from index or
1808 on-disk file to tree contents.
1809 </p>
1810 </dd>
1811 <dt class="hdlist1">
1812 --relative[=&lt;path&gt;]
1813 </dt>
1814 <dt class="hdlist1">
1815 --no-relative
1816 </dt>
1817 <dd>
1819 When run from a subdirectory of the project, it can be
1820 told to exclude changes outside the directory and show
1821 pathnames relative to it with this option. When you are
1822 not in a subdirectory (e.g. in a bare repository), you
1823 can name which subdirectory to make the output relative
1824 to by giving a &lt;path&gt; as an argument.
1825 <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config
1826 option and previous <code>--relative</code>.
1827 </p>
1828 </dd>
1829 <dt class="hdlist1">
1831 </dt>
1832 <dt class="hdlist1">
1833 --text
1834 </dt>
1835 <dd>
1837 Treat all files as text.
1838 </p>
1839 </dd>
1840 <dt class="hdlist1">
1841 --ignore-cr-at-eol
1842 </dt>
1843 <dd>
1845 Ignore carriage-return at the end of line when doing a comparison.
1846 </p>
1847 </dd>
1848 <dt class="hdlist1">
1849 --ignore-space-at-eol
1850 </dt>
1851 <dd>
1853 Ignore changes in whitespace at EOL.
1854 </p>
1855 </dd>
1856 <dt class="hdlist1">
1858 </dt>
1859 <dt class="hdlist1">
1860 --ignore-space-change
1861 </dt>
1862 <dd>
1864 Ignore changes in amount of whitespace. This ignores whitespace
1865 at line end, and considers all other sequences of one or
1866 more whitespace characters to be equivalent.
1867 </p>
1868 </dd>
1869 <dt class="hdlist1">
1871 </dt>
1872 <dt class="hdlist1">
1873 --ignore-all-space
1874 </dt>
1875 <dd>
1877 Ignore whitespace when comparing lines. This ignores
1878 differences even if one line has whitespace where the other
1879 line has none.
1880 </p>
1881 </dd>
1882 <dt class="hdlist1">
1883 --ignore-blank-lines
1884 </dt>
1885 <dd>
1887 Ignore changes whose lines are all blank.
1888 </p>
1889 </dd>
1890 <dt class="hdlist1">
1891 -I&lt;regex&gt;
1892 </dt>
1893 <dt class="hdlist1">
1894 --ignore-matching-lines=&lt;regex&gt;
1895 </dt>
1896 <dd>
1898 Ignore changes whose all lines match &lt;regex&gt;. This option may
1899 be specified more than once.
1900 </p>
1901 </dd>
1902 <dt class="hdlist1">
1903 --inter-hunk-context=&lt;lines&gt;
1904 </dt>
1905 <dd>
1907 Show the context between diff hunks, up to the specified number
1908 of lines, thereby fusing hunks that are close to each other.
1909 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
1910 is unset.
1911 </p>
1912 </dd>
1913 <dt class="hdlist1">
1915 </dt>
1916 <dt class="hdlist1">
1917 --function-context
1918 </dt>
1919 <dd>
1921 Show whole function as context lines for each change.
1922 The function names are determined in the same way as
1923 <code>git diff</code> works out patch hunk headers (see <em>Defining a
1924 custom hunk-header</em> in <a href="gitattributes.html">gitattributes(5)</a>).
1925 </p>
1926 </dd>
1927 <dt class="hdlist1">
1928 --exit-code
1929 </dt>
1930 <dd>
1932 Make the program exit with codes similar to diff(1).
1933 That is, it exits with 1 if there were differences and
1934 0 means no differences.
1935 </p>
1936 </dd>
1937 <dt class="hdlist1">
1938 --quiet
1939 </dt>
1940 <dd>
1942 Disable all output of the program. Implies <code>--exit-code</code>.
1943 Disables execution of external diff helpers whose exit code
1944 is not trusted, i.e. their respective configuration option
1945 <code>diff.trustExitCode</code> or <code>diff.&lt;driver&gt;.trustExitCode</code> or
1946 environment variable <code>GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE</code> is
1947 false.
1948 </p>
1949 </dd>
1950 <dt class="hdlist1">
1951 --ext-diff
1952 </dt>
1953 <dd>
1955 Allow an external diff helper to be executed. If you set an
1956 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1957 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1958 </p>
1959 </dd>
1960 <dt class="hdlist1">
1961 --no-ext-diff
1962 </dt>
1963 <dd>
1965 Disallow external diff drivers.
1966 </p>
1967 </dd>
1968 <dt class="hdlist1">
1969 --textconv
1970 </dt>
1971 <dt class="hdlist1">
1972 --no-textconv
1973 </dt>
1974 <dd>
1976 Allow (or disallow) external text conversion filters to be run
1977 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1978 details. Because textconv filters are typically a one-way
1979 conversion, the resulting diff is suitable for human
1980 consumption, but cannot be applied. For this reason, textconv
1981 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1982 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1983 diff plumbing commands.
1984 </p>
1985 </dd>
1986 <dt class="hdlist1">
1987 --ignore-submodules[=&lt;when&gt;]
1988 </dt>
1989 <dd>
1991 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1992 either "none", "untracked", "dirty" or "all", which is the default.
1993 Using "none" will consider the submodule modified when it either contains
1994 untracked or modified files or its HEAD differs from the commit recorded
1995 in the superproject and can be used to override any settings of the
1996 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1997 "untracked" is used submodules are not considered dirty when they only
1998 contain untracked content (but they are still scanned for modified
1999 content). Using "dirty" ignores all changes to the work tree of submodules,
2000 only changes to the commits stored in the superproject are shown (this was
2001 the behavior until 1.7.0). Using "all" hides all changes to submodules.
2002 </p>
2003 </dd>
2004 <dt class="hdlist1">
2005 --src-prefix=&lt;prefix&gt;
2006 </dt>
2007 <dd>
2009 Show the given source prefix instead of "a/".
2010 </p>
2011 </dd>
2012 <dt class="hdlist1">
2013 --dst-prefix=&lt;prefix&gt;
2014 </dt>
2015 <dd>
2017 Show the given destination prefix instead of "b/".
2018 </p>
2019 </dd>
2020 <dt class="hdlist1">
2021 --no-prefix
2022 </dt>
2023 <dd>
2025 Do not show any source or destination prefix.
2026 </p>
2027 </dd>
2028 <dt class="hdlist1">
2029 --default-prefix
2030 </dt>
2031 <dd>
2033 Use the default source and destination prefixes ("a/" and "b/").
2034 This overrides configuration variables such as <code>diff.noprefix</code>,
2035 <code>diff.srcPrefix</code>, <code>diff.dstPrefix</code>, and <code>diff.mnemonicPrefix</code>
2036 (see <code>git-config</code>(1)).
2037 </p>
2038 </dd>
2039 <dt class="hdlist1">
2040 --line-prefix=&lt;prefix&gt;
2041 </dt>
2042 <dd>
2044 Prepend an additional prefix to every line of output.
2045 </p>
2046 </dd>
2047 <dt class="hdlist1">
2048 --ita-invisible-in-index
2049 </dt>
2050 <dd>
2052 By default entries added by "git add -N" appear as an existing
2053 empty file in "git diff" and a new file in "git diff --cached".
2054 This option makes the entry appear as a new file in "git diff"
2055 and non-existent in "git diff --cached". This option could be
2056 reverted with <code>--ita-visible-in-index</code>. Both options are
2057 experimental and could be removed in future.
2058 </p>
2059 </dd>
2060 </dl></div>
2061 <div class="paragraph"><p>For more detailed explanation on these common options, see also
2062 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
2063 <div class="dlist"><dl>
2064 <dt class="hdlist1">
2065 &lt;tree-ish&gt;
2066 </dt>
2067 <dd>
2069 The id of a tree object to diff against.
2070 </p>
2071 </dd>
2072 <dt class="hdlist1">
2073 --cached
2074 </dt>
2075 <dd>
2077 Do not consider the on-disk file at all.
2078 </p>
2079 </dd>
2080 <dt class="hdlist1">
2081 --merge-base
2082 </dt>
2083 <dd>
2085 Instead of comparing &lt;tree-ish&gt; directly, use the merge base
2086 between &lt;tree-ish&gt; and HEAD instead. &lt;tree-ish&gt; must be a
2087 commit.
2088 </p>
2089 </dd>
2090 <dt class="hdlist1">
2092 </dt>
2093 <dd>
2095 By default, files recorded in the index but not checked
2096 out are reported as deleted. This flag makes
2097 <em>git diff-index</em> say that all non-checked-out files are up
2098 to date.
2099 </p>
2100 </dd>
2101 </dl></div>
2102 </div>
2103 </div>
2104 <div class="sect1">
2105 <h2 id="_raw_output_format">Raw output format</h2>
2106 <div class="sectionbody">
2107 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
2108 "git-diff-files" and "git diff --raw" are very similar.</p></div>
2109 <div class="paragraph"><p>These commands all compare two sets of things; what is
2110 compared differs:</p></div>
2111 <div class="dlist"><dl>
2112 <dt class="hdlist1">
2113 git-diff-index &lt;tree-ish&gt;
2114 </dt>
2115 <dd>
2117 compares the &lt;tree-ish&gt; and the files on the filesystem.
2118 </p>
2119 </dd>
2120 <dt class="hdlist1">
2121 git-diff-index --cached &lt;tree-ish&gt;
2122 </dt>
2123 <dd>
2125 compares the &lt;tree-ish&gt; and the index.
2126 </p>
2127 </dd>
2128 <dt class="hdlist1">
2129 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
2130 </dt>
2131 <dd>
2133 compares the trees named by the two arguments.
2134 </p>
2135 </dd>
2136 <dt class="hdlist1">
2137 git-diff-files [&lt;pattern&gt;&#8230;]
2138 </dt>
2139 <dd>
2141 compares the index and the files on the filesystem.
2142 </p>
2143 </dd>
2144 </dl></div>
2145 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
2146 what is being compared. After that, all the commands print one output
2147 line per changed file.</p></div>
2148 <div class="paragraph"><p>An output line is formatted this way:</p></div>
2149 <div class="listingblock">
2150 <div class="content">
2151 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
2152 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
2153 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
2154 create :000000 100644 0000000 1234567 A file4
2155 delete :100644 000000 1234567 0000000 D file5
2156 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2157 </div></div>
2158 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2159 <div class="olist arabic"><ol class="arabic">
2160 <li>
2162 a colon.
2163 </p>
2164 </li>
2165 <li>
2167 mode for "src"; 000000 if creation or unmerged.
2168 </p>
2169 </li>
2170 <li>
2172 a space.
2173 </p>
2174 </li>
2175 <li>
2177 mode for "dst"; 000000 if deletion or unmerged.
2178 </p>
2179 </li>
2180 <li>
2182 a space.
2183 </p>
2184 </li>
2185 <li>
2187 sha1 for "src"; 0{40} if creation or unmerged.
2188 </p>
2189 </li>
2190 <li>
2192 a space.
2193 </p>
2194 </li>
2195 <li>
2197 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".
2198 </p>
2199 </li>
2200 <li>
2202 a space.
2203 </p>
2204 </li>
2205 <li>
2207 status, followed by optional "score" number.
2208 </p>
2209 </li>
2210 <li>
2212 a tab or a NUL when <code>-z</code> option is used.
2213 </p>
2214 </li>
2215 <li>
2217 path for "src"
2218 </p>
2219 </li>
2220 <li>
2222 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2223 </p>
2224 </li>
2225 <li>
2227 path for "dst"; only exists for C or R.
2228 </p>
2229 </li>
2230 <li>
2232 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2233 </p>
2234 </li>
2235 </ol></div>
2236 <div class="paragraph"><p>Possible status letters are:</p></div>
2237 <div class="ulist"><ul>
2238 <li>
2240 A: addition of a file
2241 </p>
2242 </li>
2243 <li>
2245 C: copy of a file into a new one
2246 </p>
2247 </li>
2248 <li>
2250 D: deletion of a file
2251 </p>
2252 </li>
2253 <li>
2255 M: modification of the contents or mode of a file
2256 </p>
2257 </li>
2258 <li>
2260 R: renaming of a file
2261 </p>
2262 </li>
2263 <li>
2265 T: change in the type of the file (regular file, symbolic link or submodule)
2266 </p>
2267 </li>
2268 <li>
2270 U: file is unmerged (you must complete the merge before it can
2271 be committed)
2272 </p>
2273 </li>
2274 <li>
2276 X: "unknown" change type (most probably a bug, please report it)
2277 </p>
2278 </li>
2279 </ul></div>
2280 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2281 percentage of similarity between the source and target of the move or
2282 copy). Status letter M may be followed by a score (denoting the
2283 percentage of dissimilarity) for file rewrites.</p></div>
2284 <div class="paragraph"><p>The sha1 for "dst" is shown as all 0&#8217;s if a file on the filesystem
2285 is out of sync with the index.</p></div>
2286 <div class="paragraph"><p>Example:</p></div>
2287 <div class="listingblock">
2288 <div class="content">
2289 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2290 </div></div>
2291 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2292 quoted as explained for the configuration variable <code>core.quotePath</code>
2293 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2294 verbatim and the line is terminated by a NUL byte.</p></div>
2295 </div>
2296 </div>
2297 <div class="sect1">
2298 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2299 <div class="sectionbody">
2300 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2301 can take <code>-c</code> or <code>--cc</code> option
2302 to generate diff output also for merge commits. The output differs
2303 from the format described above in the following way:</p></div>
2304 <div class="olist arabic"><ol class="arabic">
2305 <li>
2307 there is a colon for each parent
2308 </p>
2309 </li>
2310 <li>
2312 there are more "src" modes and "src" sha1
2313 </p>
2314 </li>
2315 <li>
2317 status is concatenated status characters for each parent
2318 </p>
2319 </li>
2320 <li>
2322 no optional "score" number
2323 </p>
2324 </li>
2325 <li>
2327 tab-separated pathname(s) of the file
2328 </p>
2329 </li>
2330 </ol></div>
2331 <div class="paragraph"><p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even
2332 if the file was renamed on any side of history. With
2333 <code>--combined-all-paths</code>, the name of the path in each parent is shown
2334 followed by the name of the path in the merge commit.</p></div>
2335 <div class="paragraph"><p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p></div>
2336 <div class="listingblock">
2337 <div class="content">
2338 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
2339 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
2340 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</code></pre>
2341 </div></div>
2342 <div class="paragraph"><p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p></div>
2343 <div class="listingblock">
2344 <div class="content">
2345 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
2346 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2347 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</code></pre>
2348 </div></div>
2349 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2350 all parents.</p></div>
2351 </div>
2352 </div>
2353 <div class="sect1">
2354 <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2>
2355 <div class="sectionbody">
2356 <div class="paragraph"><p>Running
2357 <a href="git-diff.html">git-diff(1)</a>,
2358 <a href="git-log.html">git-log(1)</a>,
2359 <a href="git-show.html">git-show(1)</a>,
2360 <a href="git-diff-index.html">git-diff-index(1)</a>,
2361 <a href="git-diff-tree.html">git-diff-tree(1)</a>, or
2362 <a href="git-diff-files.html">git-diff-files(1)</a>
2363 with the <code>-p</code> option produces patch text.
2364 You can customize the creation of patch text via the
2365 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables
2366 (see <a href="git.html">git(1)</a>), and the <code>diff</code> attribute (see <a href="gitattributes.html">gitattributes(5)</a>).</p></div>
2367 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2368 diff format:</p></div>
2369 <div class="olist arabic"><ol class="arabic">
2370 <li>
2372 It is preceded by a "git diff" header that looks like this:
2373 </p>
2374 <div class="literalblock">
2375 <div class="content">
2376 <pre><code>diff --git a/file1 b/file2</code></pre>
2377 </div></div>
2378 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2379 involved. Especially, even for a creation or a deletion,
2380 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2381 <div class="paragraph"><p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2382 name of the source file of the rename/copy and the name of
2383 the file that the rename/copy produces, respectively.</p></div>
2384 </li>
2385 <li>
2387 It is followed by one or more extended header lines:
2388 </p>
2389 <div class="literalblock">
2390 <div class="content">
2391 <pre><code>old mode &lt;mode&gt;
2392 new mode &lt;mode&gt;
2393 deleted file mode &lt;mode&gt;
2394 new file mode &lt;mode&gt;
2395 copy from &lt;path&gt;
2396 copy to &lt;path&gt;
2397 rename from &lt;path&gt;
2398 rename to &lt;path&gt;
2399 similarity index &lt;number&gt;
2400 dissimilarity index &lt;number&gt;
2401 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</code></pre>
2402 </div></div>
2403 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2404 and file permission bits.</p></div>
2405 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2406 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2407 the dissimilarity index is the percentage of changed lines. It
2408 is a rounded down integer, followed by a percent sign. The
2409 similarity index value of 100% is thus reserved for two equal
2410 files, while 100% dissimilarity means that no line from the old
2411 file made it into the new one.</p></div>
2412 <div class="paragraph"><p>The index line includes the blob object names before and after the change.
2413 The &lt;mode&gt; is included if the file mode does not change; otherwise,
2414 separate lines indicate the old and the new mode.</p></div>
2415 </li>
2416 <li>
2418 Pathnames with "unusual" characters are quoted as explained for
2419 the configuration variable <code>core.quotePath</code> (see
2420 <a href="git-config.html">git-config(1)</a>).
2421 </p>
2422 </li>
2423 <li>
2425 All the <code>file1</code> files in the output refer to files before the
2426 commit, and all the <code>file2</code> files refer to files after the commit.
2427 It is incorrect to apply each change to each file sequentially. For
2428 example, this patch will swap a and b:
2429 </p>
2430 <div class="literalblock">
2431 <div class="content">
2432 <pre><code>diff --git a/a b/b
2433 rename from a
2434 rename to b
2435 diff --git a/b b/a
2436 rename from b
2437 rename to a</code></pre>
2438 </div></div>
2439 </li>
2440 <li>
2442 Hunk headers mention the name of the function to which the hunk
2443 applies. See "Defining a custom hunk-header" in
2444 <a href="gitattributes.html">gitattributes(5)</a> for details of how to tailor this to
2445 specific languages.
2446 </p>
2447 </li>
2448 </ol></div>
2449 </div>
2450 </div>
2451 <div class="sect1">
2452 <h2 id="_combined_diff_format">Combined diff format</h2>
2453 <div class="sectionbody">
2454 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2455 produce a <em>combined diff</em> when showing a merge. This is the default
2456 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2457 <a href="git-show.html">git-show(1)</a>. Note also that you can give suitable
2458 <code>--diff-merges</code> option to any of these commands to force generation of
2459 diffs in a specific format.</p></div>
2460 <div class="paragraph"><p>A "combined diff" format looks like this:</p></div>
2461 <div class="listingblock">
2462 <div class="content">
2463 <pre><code>diff --combined describe.c
2464 index fabadb8,cc95eb0..4866510
2465 --- a/describe.c
2466 +++ b/describe.c
2467 @@@ -98,20 -98,12 +98,20 @@@
2468 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2471 - static void describe(char *arg)
2472 -static void describe(struct commit *cmit, int last_one)
2473 ++static void describe(char *arg, int last_one)
2475 + unsigned char sha1[20];
2476 + struct commit *cmit;
2477 struct commit_list *list;
2478 static int initialized = 0;
2479 struct commit_name *n;
2481 + if (get_sha1(arg, sha1) &lt; 0)
2482 + usage(describe_usage);
2483 + cmit = lookup_commit_reference(sha1);
2484 + if (!cmit)
2485 + usage(describe_usage);
2487 if (!initialized) {
2488 initialized = 1;
2489 for_each_ref(get_name);</code></pre>
2490 </div></div>
2491 <div class="olist arabic"><ol class="arabic">
2492 <li>
2494 It is preceded by a "git diff" header, that looks like
2495 this (when the <code>-c</code> option is used):
2496 </p>
2497 <div class="literalblock">
2498 <div class="content">
2499 <pre><code>diff --combined file</code></pre>
2500 </div></div>
2501 <div class="paragraph"><p>or like this (when the <code>--cc</code> option is used):</p></div>
2502 <div class="literalblock">
2503 <div class="content">
2504 <pre><code>diff --cc file</code></pre>
2505 </div></div>
2506 </li>
2507 <li>
2509 It is followed by one or more extended header lines
2510 (this example shows a merge with two parents):
2511 </p>
2512 <div class="literalblock">
2513 <div class="content">
2514 <pre><code>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
2515 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
2516 new file mode &lt;mode&gt;
2517 deleted file mode &lt;mode&gt;,&lt;mode&gt;</code></pre>
2518 </div></div>
2519 <div class="paragraph"><p>The <code>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</code> line appears only if at least one of
2520 the &lt;mode&gt; is different from the rest. Extended headers with
2521 information about detected content movement (renames and
2522 copying detection) are designed to work with the diff of two
2523 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
2524 </li>
2525 <li>
2527 It is followed by a two-line from-file/to-file header:
2528 </p>
2529 <div class="literalblock">
2530 <div class="content">
2531 <pre><code>--- a/file
2532 +++ b/file</code></pre>
2533 </div></div>
2534 <div class="paragraph"><p>Similar to the two-line header for the traditional <em>unified</em> diff
2535 format, <code>/dev/null</code> is used to signal created or deleted
2536 files.</p></div>
2537 <div class="paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2538 two-line from-file/to-file, you get an N+1 line from-file/to-file header,
2539 where N is the number of parents in the merge commit:</p></div>
2540 <div class="literalblock">
2541 <div class="content">
2542 <pre><code>--- a/file
2543 --- a/file
2544 --- a/file
2545 +++ b/file</code></pre>
2546 </div></div>
2547 <div class="paragraph"><p>This extended format can be useful if rename or copy detection is
2548 active, to allow you to see the original name of the file in different
2549 parents.</p></div>
2550 </li>
2551 <li>
2553 Chunk header format is modified to prevent people from
2554 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2555 was created for review of merge commit changes, and was not
2556 meant to be applied. The change is similar to the change in the
2557 extended <em>index</em> header:
2558 </p>
2559 <div class="literalblock">
2560 <div class="content">
2561 <pre><code>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</code></pre>
2562 </div></div>
2563 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2564 header for combined diff format.</p></div>
2565 </li>
2566 </ol></div>
2567 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2568 files A and B with a single column that has <code>-</code> (minus&#8201;&#8212;&#8201;appears in A but removed in B), <code>+</code> (plus&#8201;&#8212;&#8201;missing in A but
2569 added to B), or <code>" "</code> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
2570 compares two or more files file1, file2,&#8230; with one file X, and
2571 shows how X differs from each of fileN. One column for each of
2572 fileN is prepended to the output line to note how X&#8217;s line is
2573 different from it.</p></div>
2574 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2575 fileN but it does not appear in the result. A <code>+</code> character
2576 in the column N means that the line appears in the result,
2577 and fileN does not have that line (in other words, the line was
2578 added, from the point of view of that parent).</p></div>
2579 <div class="paragraph"><p>In the above example output, the function signature was changed
2580 from both files (hence two <code>-</code> removals from both file1 and
2581 file2, plus <code>++</code> to mean one line that was added does not appear
2582 in either file1 or file2). Also, eight other lines are the same
2583 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2584 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2585 merge commit with the merge result (i.e. file1..fileN are the
2586 parents). When shown by <code>git diff-files -c</code>, it compares the
2587 two unresolved merge parents with the working tree file
2588 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2589 "their version").</p></div>
2590 </div>
2591 </div>
2592 <div class="sect1">
2593 <h2 id="_other_diff_formats">other diff formats</h2>
2594 <div class="sectionbody">
2595 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2596 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2597 output. These options can be combined with other options, such as
2598 <code>-p</code>, and are meant for human consumption.</p></div>
2599 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2600 formats the pathnames compactly by combining common prefix and suffix of
2601 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2602 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2603 <div class="listingblock">
2604 <div class="content">
2605 <pre><code>arch/{i386 =&gt; x86}/Makefile | 4 +--</code></pre>
2606 </div></div>
2607 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2608 for easier machine consumption. An entry in <code>--numstat</code> output looks
2609 like this:</p></div>
2610 <div class="listingblock">
2611 <div class="content">
2612 <pre><code>1 2 README
2613 3 1 arch/{i386 =&gt; x86}/Makefile</code></pre>
2614 </div></div>
2615 <div class="paragraph"><p>That is, from left to right:</p></div>
2616 <div class="olist arabic"><ol class="arabic">
2617 <li>
2619 the number of added lines;
2620 </p>
2621 </li>
2622 <li>
2624 a tab;
2625 </p>
2626 </li>
2627 <li>
2629 the number of deleted lines;
2630 </p>
2631 </li>
2632 <li>
2634 a tab;
2635 </p>
2636 </li>
2637 <li>
2639 pathname (possibly with rename/copy information);
2640 </p>
2641 </li>
2642 <li>
2644 a newline.
2645 </p>
2646 </li>
2647 </ol></div>
2648 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2649 <div class="listingblock">
2650 <div class="content">
2651 <pre><code>1 2 README NUL
2652 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2653 </div></div>
2654 <div class="paragraph"><p>That is:</p></div>
2655 <div class="olist arabic"><ol class="arabic">
2656 <li>
2658 the number of added lines;
2659 </p>
2660 </li>
2661 <li>
2663 a tab;
2664 </p>
2665 </li>
2666 <li>
2668 the number of deleted lines;
2669 </p>
2670 </li>
2671 <li>
2673 a tab;
2674 </p>
2675 </li>
2676 <li>
2678 a NUL (only exists if renamed/copied);
2679 </p>
2680 </li>
2681 <li>
2683 pathname in preimage;
2684 </p>
2685 </li>
2686 <li>
2688 a NUL (only exists if renamed/copied);
2689 </p>
2690 </li>
2691 <li>
2693 pathname in postimage (only exists if renamed/copied);
2694 </p>
2695 </li>
2696 <li>
2698 a NUL.
2699 </p>
2700 </li>
2701 </ol></div>
2702 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2703 scripts that read the output to tell if the current record being read is
2704 a single-path record or a rename/copy record without reading ahead.
2705 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2706 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2707 </div>
2708 </div>
2709 <div class="sect1">
2710 <h2 id="_operating_modes">OPERATING MODES</h2>
2711 <div class="sectionbody">
2712 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
2713 (using the <code>--cached</code> flag) or ask the diff logic to show any files
2714 that don&#8217;t match the stat state as being "tentatively changed". Both
2715 of these operations are very useful indeed.</p></div>
2716 </div>
2717 </div>
2718 <div class="sect1">
2719 <h2 id="_cached_mode">CACHED MODE</h2>
2720 <div class="sectionbody">
2721 <div class="paragraph"><p>If <code>--cached</code> is specified, it allows you to ask:</p></div>
2722 <div class="literalblock">
2723 <div class="content">
2724 <pre><code>show me the differences between HEAD and the current index
2725 contents (the ones I'd write using 'git write-tree')</code></pre>
2726 </div></div>
2727 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
2728 some files in the index and are ready to commit. You want to see exactly
2729 <strong>what</strong> you are going to commit, without having to write a new tree
2730 object and compare it that way, and to do that, you just do</p></div>
2731 <div class="literalblock">
2732 <div class="content">
2733 <pre><code>git diff-index --cached HEAD</code></pre>
2734 </div></div>
2735 <div class="paragraph"><p>Example: let&#8217;s say I had renamed <code>commit.c</code> to <code>git-commit.c</code>, and I had
2736 done an <code>update-index</code> to make that effective in the index file.
2737 <code>git diff-files</code> wouldn&#8217;t show anything at all, since the index file
2738 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
2739 <div class="literalblock">
2740 <div class="content">
2741 <pre><code>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
2742 :100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D commit.c
2743 :000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git-commit.c</code></pre>
2744 </div></div>
2745 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
2746 <div class="paragraph"><p>In fact, <code>git diff-index --cached</code> <strong>should</strong> always be entirely equivalent to
2747 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
2748 nicer for the case where you just want to check where you are.</p></div>
2749 <div class="paragraph"><p>So doing a <code>git diff-index --cached</code> is basically very useful when you are
2750 asking yourself "what have I already marked for being committed, and
2751 what&#8217;s the difference to a previous tree".</p></div>
2752 </div>
2753 </div>
2754 <div class="sect1">
2755 <h2 id="_non_cached_mode">NON-CACHED MODE</h2>
2756 <div class="sectionbody">
2757 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
2758 the more useful of the two in that what it does can&#8217;t be emulated with
2759 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
2760 The non-cached version asks the question:</p></div>
2761 <div class="literalblock">
2762 <div class="content">
2763 <pre><code>show me the differences between HEAD and the currently checked out
2764 tree - index contents _and_ files that aren't up to date</code></pre>
2765 </div></div>
2766 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
2767 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
2768 output to a tee, but with a twist.</p></div>
2769 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
2770 a backing store thing for it, and we use the magic "all-zero" sha1 to
2771 show that. So let&#8217;s say that you have edited <code>kernel/sched.c</code>, but
2772 have not actually done a <em>git update-index</em> on it yet - there is no
2773 "object" associated with the new state, and you get:</p></div>
2774 <div class="literalblock">
2775 <div class="content">
2776 <pre><code>torvalds@ppc970:~/v2.6/linux&gt; git diff-index --abbrev HEAD
2777 :100644 100644 7476bb5ba 000000000 M kernel/sched.c</code></pre>
2778 </div></div>
2779 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <code>kernel/sched.c</code> is
2780 not up to date and may contain new stuff. The all-zero sha1 means that to
2781 get the real diff, you need to look at the object in the working directory
2782 directly rather than do an object-to-object diff.</p></div>
2783 <div class="admonitionblock">
2784 <table><tr>
2785 <td class="icon">
2786 <div class="title">Note</div>
2787 </td>
2788 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
2789 actually look at the contents of the file at all. So maybe
2790 <code>kernel/sched.c</code> hasn&#8217;t actually changed, and it&#8217;s just that you
2791 touched it. In either case, it&#8217;s a note that you need to
2792 <em>git update-index</em> it to make the index be in sync.</td>
2793 </tr></table>
2794 </div>
2795 <div class="admonitionblock">
2796 <table><tr>
2797 <td class="icon">
2798 <div class="title">Note</div>
2799 </td>
2800 <td class="content">You can have a mixture of files show up as "has been updated"
2801 and "is still dirty in the working directory" together. You can always
2802 tell which file is in which state, since the "has been updated" ones
2803 show a valid sha1, and the "not in sync with the index" ones will
2804 always have the special all-zero sha1.</td>
2805 </tr></table>
2806 </div>
2807 </div>
2808 </div>
2809 <div class="sect1">
2810 <h2 id="_git">GIT</h2>
2811 <div class="sectionbody">
2812 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2813 </div>
2814 </div>
2815 </div>
2816 <div id="footnotes"><hr /></div>
2817 <div id="footer">
2818 <div id="footer-text">
2819 Last updated
2820 2023-10-23 14:43:46 PDT
2821 </div>
2822 </div>
2823 </body>
2824 </html>