Autogenerated HTML docs for v2.42.0-241-g6bdb5
[git-htmldocs.git] / git-diff-files.html
blobb4de7d6faeb9c7759ea3416de022e57c9f71fa01
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-files(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-files(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-diff-files -
743 Compares files in the working tree and the 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-files</em> [-q] [-0 | -1 | -2 | -3 | -c | --cc] [&lt;common-diff-options&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>Compares the files in the working tree and the index. When paths
761 are specified, compares only those named paths. Otherwise all
762 entries in the index are compared. The output format is the
763 same as for <em>git diff-index</em> and <em>git diff-tree</em>.</p></div>
764 </div>
765 </div>
766 <div class="sect1">
767 <h2 id="_options">OPTIONS</h2>
768 <div class="sectionbody">
769 <div class="dlist"><dl>
770 <dt class="hdlist1">
772 </dt>
773 <dt class="hdlist1">
775 </dt>
776 <dt class="hdlist1">
777 --patch
778 </dt>
779 <dd>
781 Generate patch (see <a href="#generate_patch_text_with_p">[generate_patch_text_with_p]</a>).
782 </p>
783 </dd>
784 <dt class="hdlist1">
786 </dt>
787 <dt class="hdlist1">
788 --no-patch
789 </dt>
790 <dd>
792 Suppress all output from the diff machinery. Useful for
793 commands like <code>git show</code> that show the patch by default to
794 squelch their output, or to cancel the effect of options like
795 <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.
796 </p>
797 </dd>
798 <dt class="hdlist1">
799 -U&lt;n&gt;
800 </dt>
801 <dt class="hdlist1">
802 --unified=&lt;n&gt;
803 </dt>
804 <dd>
806 Generate diffs with &lt;n&gt; lines of context instead of
807 the usual three.
808 Implies <code>--patch</code>.
809 </p>
810 </dd>
811 <dt class="hdlist1">
812 --output=&lt;file&gt;
813 </dt>
814 <dd>
816 Output to a specific file instead of stdout.
817 </p>
818 </dd>
819 <dt class="hdlist1">
820 --output-indicator-new=&lt;char&gt;
821 </dt>
822 <dt class="hdlist1">
823 --output-indicator-old=&lt;char&gt;
824 </dt>
825 <dt class="hdlist1">
826 --output-indicator-context=&lt;char&gt;
827 </dt>
828 <dd>
830 Specify the character used to indicate new, old or context
831 lines in the generated patch. Normally they are <em>+</em>, <em>-</em> and
832 ' ' respectively.
833 </p>
834 </dd>
835 <dt class="hdlist1">
836 --raw
837 </dt>
838 <dd>
840 Generate the diff in raw format.
841 This is the default.
842 </p>
843 </dd>
844 <dt class="hdlist1">
845 --patch-with-raw
846 </dt>
847 <dd>
849 Synonym for <code>-p --raw</code>.
850 </p>
851 </dd>
852 <dt class="hdlist1">
853 --indent-heuristic
854 </dt>
855 <dd>
857 Enable the heuristic that shifts diff hunk boundaries to make patches
858 easier to read. This is the default.
859 </p>
860 </dd>
861 <dt class="hdlist1">
862 --no-indent-heuristic
863 </dt>
864 <dd>
866 Disable the indent heuristic.
867 </p>
868 </dd>
869 <dt class="hdlist1">
870 --minimal
871 </dt>
872 <dd>
874 Spend extra time to make sure the smallest possible
875 diff is produced.
876 </p>
877 </dd>
878 <dt class="hdlist1">
879 --patience
880 </dt>
881 <dd>
883 Generate a diff using the "patience diff" algorithm.
884 </p>
885 </dd>
886 <dt class="hdlist1">
887 --histogram
888 </dt>
889 <dd>
891 Generate a diff using the "histogram diff" algorithm.
892 </p>
893 </dd>
894 <dt class="hdlist1">
895 --anchored=&lt;text&gt;
896 </dt>
897 <dd>
899 Generate a diff using the "anchored diff" algorithm.
900 </p>
901 <div class="paragraph"><p>This option may be specified more than once.</p></div>
902 <div class="paragraph"><p>If a line exists in both the source and destination, exists only once,
903 and starts with this text, this algorithm attempts to prevent it from
904 appearing as a deletion or addition in the output. It uses the "patience
905 diff" algorithm internally.</p></div>
906 </dd>
907 <dt class="hdlist1">
908 --diff-algorithm={patience|minimal|histogram|myers}
909 </dt>
910 <dd>
912 Choose a diff algorithm. The variants are as follows:
913 </p>
914 <div class="openblock">
915 <div class="content">
916 <div class="dlist"><dl>
917 <dt class="hdlist1">
918 <code>default</code>, <code>myers</code>
919 </dt>
920 <dd>
922 The basic greedy diff algorithm. Currently, this is the default.
923 </p>
924 </dd>
925 <dt class="hdlist1">
926 <code>minimal</code>
927 </dt>
928 <dd>
930 Spend extra time to make sure the smallest possible diff is
931 produced.
932 </p>
933 </dd>
934 <dt class="hdlist1">
935 <code>patience</code>
936 </dt>
937 <dd>
939 Use "patience diff" algorithm when generating patches.
940 </p>
941 </dd>
942 <dt class="hdlist1">
943 <code>histogram</code>
944 </dt>
945 <dd>
947 This algorithm extends the patience algorithm to "support
948 low-occurrence common elements".
949 </p>
950 </dd>
951 </dl></div>
952 </div></div>
953 <div class="paragraph"><p>For instance, if you configured the <code>diff.algorithm</code> variable to a
954 non-default value and want to use the default one, then you
955 have to use <code>--diff-algorithm=default</code> option.</p></div>
956 </dd>
957 <dt class="hdlist1">
958 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
959 </dt>
960 <dd>
962 Generate a diffstat. By default, as much space as necessary
963 will be used for the filename part, and the rest for the graph
964 part. Maximum width defaults to terminal width, or 80 columns
965 if not connected to a terminal, and can be overridden by
966 <code>&lt;width&gt;</code>. The width of the filename part can be limited by
967 giving another width <code>&lt;name-width&gt;</code> after a comma. The width
968 of the graph part can be limited by using
969 <code>--stat-graph-width=&lt;width&gt;</code> (affects all commands generating
970 a stat graph) or by setting <code>diff.statGraphWidth=&lt;width&gt;</code>
971 (does not affect <code>git format-patch</code>).
972 By giving a third parameter <code>&lt;count&gt;</code>, you can limit the
973 output to the first <code>&lt;count&gt;</code> lines, followed by <code>...</code> if
974 there are more.
975 </p>
976 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=&lt;width&gt;</code>,
977 <code>--stat-name-width=&lt;name-width&gt;</code> and <code>--stat-count=&lt;count&gt;</code>.</p></div>
978 </dd>
979 <dt class="hdlist1">
980 --compact-summary
981 </dt>
982 <dd>
984 Output a condensed summary of extended header information such
985 as file creations or deletions ("new" or "gone", optionally "+l"
986 if it&#8217;s a symlink) and mode changes ("+x" or "-x" for adding
987 or removing executable bit respectively) in diffstat. The
988 information is put between the filename part and the graph
989 part. Implies <code>--stat</code>.
990 </p>
991 </dd>
992 <dt class="hdlist1">
993 --numstat
994 </dt>
995 <dd>
997 Similar to <code>--stat</code>, but shows number of added and
998 deleted lines in decimal notation and pathname without
999 abbreviation, to make it more machine friendly. For
1000 binary files, outputs two <code>-</code> instead of saying
1001 <code>0 0</code>.
1002 </p>
1003 </dd>
1004 <dt class="hdlist1">
1005 --shortstat
1006 </dt>
1007 <dd>
1009 Output only the last line of the <code>--stat</code> format containing total
1010 number of modified files, as well as number of added and deleted
1011 lines.
1012 </p>
1013 </dd>
1014 <dt class="hdlist1">
1015 -X[&lt;param1,param2,&#8230;&gt;]
1016 </dt>
1017 <dt class="hdlist1">
1018 --dirstat[=&lt;param1,param2,&#8230;&gt;]
1019 </dt>
1020 <dd>
1022 Output the distribution of relative amount of changes for each
1023 sub-directory. The behavior of <code>--dirstat</code> can be customized by
1024 passing it a comma separated list of parameters.
1025 The defaults are controlled by the <code>diff.dirstat</code> configuration
1026 variable (see <a href="git-config.html">git-config(1)</a>).
1027 The following parameters are available:
1028 </p>
1029 <div class="openblock">
1030 <div class="content">
1031 <div class="dlist"><dl>
1032 <dt class="hdlist1">
1033 <code>changes</code>
1034 </dt>
1035 <dd>
1037 Compute the dirstat numbers by counting the lines that have been
1038 removed from the source, or added to the destination. This ignores
1039 the amount of pure code movements within a file. In other words,
1040 rearranging lines in a file is not counted as much as other changes.
1041 This is the default behavior when no parameter is given.
1042 </p>
1043 </dd>
1044 <dt class="hdlist1">
1045 <code>lines</code>
1046 </dt>
1047 <dd>
1049 Compute the dirstat numbers by doing the regular line-based diff
1050 analysis, and summing the removed/added line counts. (For binary
1051 files, count 64-byte chunks instead, since binary files have no
1052 natural concept of lines). This is a more expensive <code>--dirstat</code>
1053 behavior than the <code>changes</code> behavior, but it does count rearranged
1054 lines within a file as much as other changes. The resulting output
1055 is consistent with what you get from the other <code>--*stat</code> options.
1056 </p>
1057 </dd>
1058 <dt class="hdlist1">
1059 <code>files</code>
1060 </dt>
1061 <dd>
1063 Compute the dirstat numbers by counting the number of files changed.
1064 Each changed file counts equally in the dirstat analysis. This is
1065 the computationally cheapest <code>--dirstat</code> behavior, since it does
1066 not have to look at the file contents at all.
1067 </p>
1068 </dd>
1069 <dt class="hdlist1">
1070 <code>cumulative</code>
1071 </dt>
1072 <dd>
1074 Count changes in a child directory for the parent directory as well.
1075 Note that when using <code>cumulative</code>, the sum of the percentages
1076 reported may exceed 100%. The default (non-cumulative) behavior can
1077 be specified with the <code>noncumulative</code> parameter.
1078 </p>
1079 </dd>
1080 <dt class="hdlist1">
1081 &lt;limit&gt;
1082 </dt>
1083 <dd>
1085 An integer parameter specifies a cut-off percent (3% by default).
1086 Directories contributing less than this percentage of the changes
1087 are not shown in the output.
1088 </p>
1089 </dd>
1090 </dl></div>
1091 </div></div>
1092 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1093 directories with less than 10% of the total amount of changed files,
1094 and accumulating child directory counts in the parent directories:
1095 <code>--dirstat=files,10,cumulative</code>.</p></div>
1096 </dd>
1097 <dt class="hdlist1">
1098 --cumulative
1099 </dt>
1100 <dd>
1102 Synonym for --dirstat=cumulative
1103 </p>
1104 </dd>
1105 <dt class="hdlist1">
1106 --dirstat-by-file[=&lt;param1,param2&gt;&#8230;]
1107 </dt>
1108 <dd>
1110 Synonym for --dirstat=files,param1,param2&#8230;
1111 </p>
1112 </dd>
1113 <dt class="hdlist1">
1114 --summary
1115 </dt>
1116 <dd>
1118 Output a condensed summary of extended header information
1119 such as creations, renames and mode changes.
1120 </p>
1121 </dd>
1122 <dt class="hdlist1">
1123 --patch-with-stat
1124 </dt>
1125 <dd>
1127 Synonym for <code>-p --stat</code>.
1128 </p>
1129 </dd>
1130 <dt class="hdlist1">
1132 </dt>
1133 <dd>
1135 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1136 given, do not munge pathnames and use NULs as output field terminators.
1137 </p>
1138 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1139 explained for the configuration variable <code>core.quotePath</code> (see
1140 <a href="git-config.html">git-config(1)</a>).</p></div>
1141 </dd>
1142 <dt class="hdlist1">
1143 --name-only
1144 </dt>
1145 <dd>
1147 Show only names of changed files. The file names are often encoded in UTF-8.
1148 For more information see the discussion about encoding in the <a href="git-log.html">git-log(1)</a>
1149 manual page.
1150 </p>
1151 </dd>
1152 <dt class="hdlist1">
1153 --name-status
1154 </dt>
1155 <dd>
1157 Show only names and status of changed files. See the description
1158 of the <code>--diff-filter</code> option on what the status letters mean.
1159 Just like <code>--name-only</code> the file names are often encoded in UTF-8.
1160 </p>
1161 </dd>
1162 <dt class="hdlist1">
1163 --submodule[=&lt;format&gt;]
1164 </dt>
1165 <dd>
1167 Specify how differences in submodules are shown. When specifying
1168 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1169 shows the names of the commits at the beginning and end of the range.
1170 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1171 format is used. This format lists the commits in the range like
1172 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1173 is specified, the <em>diff</em> format is used. This format shows an
1174 inline diff of the changes in the submodule contents between the
1175 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1176 if the config option is unset.
1177 </p>
1178 </dd>
1179 <dt class="hdlist1">
1180 --color[=&lt;when&gt;]
1181 </dt>
1182 <dd>
1184 Show colored diff.
1185 <code>--color</code> (i.e. without <em>=&lt;when&gt;</em>) is the same as <code>--color=always</code>.
1186 <em>&lt;when&gt;</em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1187 </p>
1188 </dd>
1189 <dt class="hdlist1">
1190 --no-color
1191 </dt>
1192 <dd>
1194 Turn off colored diff.
1195 It is the same as <code>--color=never</code>.
1196 </p>
1197 </dd>
1198 <dt class="hdlist1">
1199 --color-moved[=&lt;mode&gt;]
1200 </dt>
1201 <dd>
1203 Moved lines of code are colored differently.
1204 The &lt;mode&gt; defaults to <em>no</em> if the option is not given
1205 and to <em>zebra</em> if the option with no mode is given.
1206 The mode must be one of:
1207 </p>
1208 <div class="openblock">
1209 <div class="content">
1210 <div class="dlist"><dl>
1211 <dt class="hdlist1">
1213 </dt>
1214 <dd>
1216 Moved lines are not highlighted.
1217 </p>
1218 </dd>
1219 <dt class="hdlist1">
1220 default
1221 </dt>
1222 <dd>
1224 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1225 in the future.
1226 </p>
1227 </dd>
1228 <dt class="hdlist1">
1229 plain
1230 </dt>
1231 <dd>
1233 Any line that is added in one location and was removed
1234 in another location will be colored with <em>color.diff.newMoved</em>.
1235 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1236 that are added somewhere else in the diff. This mode picks up any
1237 moved line, but it is not very useful in a review to determine
1238 if a block of code was moved without permutation.
1239 </p>
1240 </dd>
1241 <dt class="hdlist1">
1242 blocks
1243 </dt>
1244 <dd>
1246 Blocks of moved text of at least 20 alphanumeric characters
1247 are detected greedily. The detected blocks are
1248 painted using either the <em>color.diff.{old,new}Moved</em> color.
1249 Adjacent blocks cannot be told apart.
1250 </p>
1251 </dd>
1252 <dt class="hdlist1">
1253 zebra
1254 </dt>
1255 <dd>
1257 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1258 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1259 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1260 the two colors indicates that a new block was detected.
1261 </p>
1262 </dd>
1263 <dt class="hdlist1">
1264 dimmed-zebra
1265 </dt>
1266 <dd>
1268 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1269 of moved code is performed. The bordering lines of two adjacent
1270 blocks are considered interesting, the rest is uninteresting.
1271 <code>dimmed_zebra</code> is a deprecated synonym.
1272 </p>
1273 </dd>
1274 </dl></div>
1275 </div></div>
1276 </dd>
1277 <dt class="hdlist1">
1278 --no-color-moved
1279 </dt>
1280 <dd>
1282 Turn off move detection. This can be used to override configuration
1283 settings. It is the same as <code>--color-moved=no</code>.
1284 </p>
1285 </dd>
1286 <dt class="hdlist1">
1287 --color-moved-ws=&lt;modes&gt;
1288 </dt>
1289 <dd>
1291 This configures how whitespace is ignored when performing the
1292 move detection for <code>--color-moved</code>.
1293 These modes can be given as a comma separated list:
1294 </p>
1295 <div class="openblock">
1296 <div class="content">
1297 <div class="dlist"><dl>
1298 <dt class="hdlist1">
1300 </dt>
1301 <dd>
1303 Do not ignore whitespace when performing move detection.
1304 </p>
1305 </dd>
1306 <dt class="hdlist1">
1307 ignore-space-at-eol
1308 </dt>
1309 <dd>
1311 Ignore changes in whitespace at EOL.
1312 </p>
1313 </dd>
1314 <dt class="hdlist1">
1315 ignore-space-change
1316 </dt>
1317 <dd>
1319 Ignore changes in amount of whitespace. This ignores whitespace
1320 at line end, and considers all other sequences of one or
1321 more whitespace characters to be equivalent.
1322 </p>
1323 </dd>
1324 <dt class="hdlist1">
1325 ignore-all-space
1326 </dt>
1327 <dd>
1329 Ignore whitespace when comparing lines. This ignores differences
1330 even if one line has whitespace where the other line has none.
1331 </p>
1332 </dd>
1333 <dt class="hdlist1">
1334 allow-indentation-change
1335 </dt>
1336 <dd>
1338 Initially ignore any whitespace in the move detection, then
1339 group the moved code blocks only into a block if the change in
1340 whitespace is the same per line. This is incompatible with the
1341 other modes.
1342 </p>
1343 </dd>
1344 </dl></div>
1345 </div></div>
1346 </dd>
1347 <dt class="hdlist1">
1348 --no-color-moved-ws
1349 </dt>
1350 <dd>
1352 Do not ignore whitespace when performing move detection. This can be
1353 used to override configuration settings. It is the same as
1354 <code>--color-moved-ws=no</code>.
1355 </p>
1356 </dd>
1357 <dt class="hdlist1">
1358 --word-diff[=&lt;mode&gt;]
1359 </dt>
1360 <dd>
1362 Show a word diff, using the &lt;mode&gt; to delimit changed words.
1363 By default, words are delimited by whitespace; see
1364 <code>--word-diff-regex</code> below. The &lt;mode&gt; defaults to <em>plain</em>, and
1365 must be one of:
1366 </p>
1367 <div class="openblock">
1368 <div class="content">
1369 <div class="dlist"><dl>
1370 <dt class="hdlist1">
1371 color
1372 </dt>
1373 <dd>
1375 Highlight changed words using only colors. Implies <code>--color</code>.
1376 </p>
1377 </dd>
1378 <dt class="hdlist1">
1379 plain
1380 </dt>
1381 <dd>
1383 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1384 attempts to escape the delimiters if they appear in the input,
1385 so the output may be ambiguous.
1386 </p>
1387 </dd>
1388 <dt class="hdlist1">
1389 porcelain
1390 </dt>
1391 <dd>
1393 Use a special line-based format intended for script
1394 consumption. Added/removed/unchanged runs are printed in the
1395 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1396 character at the beginning of the line and extending to the
1397 end of the line. Newlines in the input are represented by a
1398 tilde <code>~</code> on a line of its own.
1399 </p>
1400 </dd>
1401 <dt class="hdlist1">
1402 none
1403 </dt>
1404 <dd>
1406 Disable word diff again.
1407 </p>
1408 </dd>
1409 </dl></div>
1410 </div></div>
1411 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1412 highlight the changed parts in all modes if enabled.</p></div>
1413 </dd>
1414 <dt class="hdlist1">
1415 --word-diff-regex=&lt;regex&gt;
1416 </dt>
1417 <dd>
1419 Use &lt;regex&gt; to decide what a word is, instead of considering
1420 runs of non-whitespace to be a word. Also implies
1421 <code>--word-diff</code> unless it was already enabled.
1422 </p>
1423 <div class="paragraph"><p>Every non-overlapping match of the
1424 &lt;regex&gt; is considered a word. Anything between these matches is
1425 considered whitespace and ignored(!) for the purposes of finding
1426 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1427 expression to make sure that it matches all non-whitespace characters.
1428 A match that contains a newline is silently truncated(!) at the
1429 newline.</p></div>
1430 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1431 and, correspondingly, show differences character by character.</p></div>
1432 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1433 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1434 overrides any diff driver or configuration setting. Diff drivers
1435 override configuration settings.</p></div>
1436 </dd>
1437 <dt class="hdlist1">
1438 --color-words[=&lt;regex&gt;]
1439 </dt>
1440 <dd>
1442 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1443 specified) <code>--word-diff-regex=&lt;regex&gt;</code>.
1444 </p>
1445 </dd>
1446 <dt class="hdlist1">
1447 --no-renames
1448 </dt>
1449 <dd>
1451 Turn off rename detection, even when the configuration
1452 file gives the default to do so.
1453 </p>
1454 </dd>
1455 <dt class="hdlist1">
1456 --[no-]rename-empty
1457 </dt>
1458 <dd>
1460 Whether to use empty blobs as rename source.
1461 </p>
1462 </dd>
1463 <dt class="hdlist1">
1464 --check
1465 </dt>
1466 <dd>
1468 Warn if changes introduce conflict markers or whitespace errors.
1469 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1470 configuration. By default, trailing whitespaces (including
1471 lines that consist solely of whitespaces) and a space character
1472 that is immediately followed by a tab character inside the
1473 initial indent of the line are considered whitespace errors.
1474 Exits with non-zero status if problems are found. Not compatible
1475 with --exit-code.
1476 </p>
1477 </dd>
1478 <dt class="hdlist1">
1479 --ws-error-highlight=&lt;kind&gt;
1480 </dt>
1481 <dd>
1483 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1484 lines of the diff. Multiple values are separated by comma,
1485 <code>none</code> resets previous values, <code>default</code> reset the list to
1486 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1487 this option is not given, and the configuration variable
1488 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1489 <code>new</code> lines are highlighted. The whitespace errors are colored
1490 with <code>color.diff.whitespace</code>.
1491 </p>
1492 </dd>
1493 <dt class="hdlist1">
1494 --full-index
1495 </dt>
1496 <dd>
1498 Instead of the first handful of characters, show the full
1499 pre- and post-image blob object names on the "index"
1500 line when generating patch format output.
1501 </p>
1502 </dd>
1503 <dt class="hdlist1">
1504 --binary
1505 </dt>
1506 <dd>
1508 In addition to <code>--full-index</code>, output a binary diff that
1509 can be applied with <code>git-apply</code>.
1510 Implies <code>--patch</code>.
1511 </p>
1512 </dd>
1513 <dt class="hdlist1">
1514 --abbrev[=&lt;n&gt;]
1515 </dt>
1516 <dd>
1518 Instead of showing the full 40-byte hexadecimal object
1519 name in diff-raw format output and diff-tree header
1520 lines, show the shortest prefix that is at least <em>&lt;n&gt;</em>
1521 hexdigits long that uniquely refers the object.
1522 In diff-patch output format, <code>--full-index</code> takes higher
1523 precedence, i.e. if <code>--full-index</code> is specified, full blob
1524 names will be shown regardless of <code>--abbrev</code>.
1525 Non default number of digits can be specified with <code>--abbrev=&lt;n&gt;</code>.
1526 </p>
1527 </dd>
1528 <dt class="hdlist1">
1529 -B[&lt;n&gt;][/&lt;m&gt;]
1530 </dt>
1531 <dt class="hdlist1">
1532 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1533 </dt>
1534 <dd>
1536 Break complete rewrite changes into pairs of delete and
1537 create. This serves two purposes:
1538 </p>
1539 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1540 not as a series of deletion and insertion mixed together with a very
1541 few lines that happen to match textually as the context, but as a
1542 single deletion of everything old followed by a single insertion of
1543 everything new, and the number <code>m</code> controls this aspect of the -B
1544 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1545 original should remain in the result for Git to consider it a total
1546 rewrite (i.e. otherwise the resulting patch will be a series of
1547 deletion and insertion mixed together with context lines).</p></div>
1548 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1549 source of a rename (usually -M only considers a file that disappeared
1550 as the source of a rename), and the number <code>n</code> controls this aspect of
1551 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1552 addition and deletion compared to 20% or more of the file&#8217;s size are
1553 eligible for being picked up as a possible source of a rename to
1554 another file.</p></div>
1555 </dd>
1556 <dt class="hdlist1">
1557 -M[&lt;n&gt;]
1558 </dt>
1559 <dt class="hdlist1">
1560 --find-renames[=&lt;n&gt;]
1561 </dt>
1562 <dd>
1564 Detect renames.
1565 If <code>n</code> is specified, it is a threshold on the similarity
1566 index (i.e. amount of addition/deletions compared to the
1567 file&#8217;s size). For example, <code>-M90%</code> means Git should consider a
1568 delete/add pair to be a rename if more than 90% of the file
1569 hasn&#8217;t changed. Without a <code>%</code> sign, the number is to be read as
1570 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1571 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1572 the same as <code>-M5%</code>. To limit detection to exact renames, use
1573 <code>-M100%</code>. The default similarity index is 50%.
1574 </p>
1575 </dd>
1576 <dt class="hdlist1">
1577 -C[&lt;n&gt;]
1578 </dt>
1579 <dt class="hdlist1">
1580 --find-copies[=&lt;n&gt;]
1581 </dt>
1582 <dd>
1584 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1585 If <code>n</code> is specified, it has the same meaning as for <code>-M&lt;n&gt;</code>.
1586 </p>
1587 </dd>
1588 <dt class="hdlist1">
1589 --find-copies-harder
1590 </dt>
1591 <dd>
1593 For performance reasons, by default, <code>-C</code> option finds copies only
1594 if the original file of the copy was modified in the same
1595 changeset. This flag makes the command
1596 inspect unmodified files as candidates for the source of
1597 copy. This is a very expensive operation for large
1598 projects, so use it with caution. Giving more than one
1599 <code>-C</code> option has the same effect.
1600 </p>
1601 </dd>
1602 <dt class="hdlist1">
1604 </dt>
1605 <dt class="hdlist1">
1606 --irreversible-delete
1607 </dt>
1608 <dd>
1610 Omit the preimage for deletes, i.e. print only the header but not
1611 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1612 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1613 solely for people who want to just concentrate on reviewing the
1614 text after the change. In addition, the output obviously lacks
1615 enough information to apply such a patch in reverse, even manually,
1616 hence the name of the option.
1617 </p>
1618 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1619 of a delete/create pair.</p></div>
1620 </dd>
1621 <dt class="hdlist1">
1622 -l&lt;num&gt;
1623 </dt>
1624 <dd>
1626 The <code>-M</code> and <code>-C</code> options involve some preliminary steps that
1627 can detect subsets of renames/copies cheaply, followed by an
1628 exhaustive fallback portion that compares all remaining
1629 unpaired destinations to all relevant sources. (For renames,
1630 only remaining unpaired sources are relevant; for copies, all
1631 original sources are relevant.) For N sources and
1632 destinations, this exhaustive check is O(N^2). This option
1633 prevents the exhaustive portion of rename/copy detection from
1634 running if the number of source/destination files involved
1635 exceeds the specified number. Defaults to diff.renameLimit.
1636 Note that a value of 0 is treated as unlimited.
1637 </p>
1638 </dd>
1639 <dt class="hdlist1">
1640 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1641 </dt>
1642 <dd>
1644 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1645 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1646 type (i.e. regular file, symlink, submodule, &#8230;) changed (<code>T</code>),
1647 are Unmerged (<code>U</code>), are
1648 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1649 Any combination of the filter characters (including none) can be used.
1650 When <code>*</code> (All-or-none) is added to the combination, all
1651 paths are selected if there is any file that matches
1652 other criteria in the comparison; if there is no file
1653 that matches other criteria, nothing is selected.
1654 </p>
1655 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1656 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1657 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1658 renamed entries cannot appear if detection for those types is disabled.</p></div>
1659 </dd>
1660 <dt class="hdlist1">
1661 -S&lt;string&gt;
1662 </dt>
1663 <dd>
1665 Look for differences that change the number of occurrences of
1666 the specified string (i.e. addition/deletion) in a file.
1667 Intended for the scripter&#8217;s use.
1668 </p>
1669 <div class="paragraph"><p>It is useful when you&#8217;re looking for an exact block of code (like a
1670 struct), and want to know the history of that block since it first
1671 came into being: use the feature iteratively to feed the interesting
1672 block in the preimage back into <code>-S</code>, and keep going until you get the
1673 very first version of the block.</p></div>
1674 <div class="paragraph"><p>Binary files are searched as well.</p></div>
1675 </dd>
1676 <dt class="hdlist1">
1677 -G&lt;regex&gt;
1678 </dt>
1679 <dd>
1681 Look for differences whose patch text contains added/removed
1682 lines that match &lt;regex&gt;.
1683 </p>
1684 <div class="paragraph"><p>To illustrate the difference between <code>-S&lt;regex&gt; --pickaxe-regex</code> and
1685 <code>-G&lt;regex&gt;</code>, consider a commit with the following diff in the same
1686 file:</p></div>
1687 <div class="listingblock">
1688 <div class="content">
1689 <pre><code>+ return frotz(nitfol, two-&gt;ptr, 1, 0);
1691 - hit = frotz(nitfol, mf2.ptr, 1, 0);</code></pre>
1692 </div></div>
1693 <div class="paragraph"><p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log
1694 -S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of
1695 occurrences of that string did not change).</p></div>
1696 <div class="paragraph"><p>Unless <code>--text</code> is supplied patches of binary files without a textconv
1697 filter will be ignored.</p></div>
1698 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1699 information.</p></div>
1700 </dd>
1701 <dt class="hdlist1">
1702 --find-object=&lt;object-id&gt;
1703 </dt>
1704 <dd>
1706 Look for differences that change the number of occurrences of
1707 the specified object. Similar to <code>-S</code>, just the argument is different
1708 in that it doesn&#8217;t search for a specific string but for a specific
1709 object id.
1710 </p>
1711 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1712 <code>git-log</code> to also find trees.</p></div>
1713 </dd>
1714 <dt class="hdlist1">
1715 --pickaxe-all
1716 </dt>
1717 <dd>
1719 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1720 changeset, not just the files that contain the change
1721 in &lt;string&gt;.
1722 </p>
1723 </dd>
1724 <dt class="hdlist1">
1725 --pickaxe-regex
1726 </dt>
1727 <dd>
1729 Treat the &lt;string&gt; given to <code>-S</code> as an extended POSIX regular
1730 expression to match.
1731 </p>
1732 </dd>
1733 <dt class="hdlist1">
1734 -O&lt;orderfile&gt;
1735 </dt>
1736 <dd>
1738 Control the order in which files appear in the output.
1739 This overrides the <code>diff.orderFile</code> configuration variable
1740 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1741 use <code>-O/dev/null</code>.
1742 </p>
1743 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1744 &lt;orderfile&gt;.
1745 All files with pathnames that match the first pattern are output
1746 first, all files with pathnames that match the second pattern (but not
1747 the first) are output next, and so on.
1748 All files with pathnames that do not match any pattern are output
1749 last, as if there was an implicit match-all pattern at the end of the
1750 file.
1751 If multiple pathnames have the same rank (they match the same pattern
1752 but no earlier patterns), their output order relative to each other is
1753 the normal order.</p></div>
1754 <div class="paragraph"><p>&lt;orderfile&gt; is parsed as follows:</p></div>
1755 <div class="openblock">
1756 <div class="content">
1757 <div class="ulist"><ul>
1758 <li>
1760 Blank lines are ignored, so they can be used as separators for
1761 readability.
1762 </p>
1763 </li>
1764 <li>
1766 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1767 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1768 pattern if it starts with a hash.
1769 </p>
1770 </li>
1771 <li>
1773 Each other line contains a single pattern.
1774 </p>
1775 </li>
1776 </ul></div>
1777 </div></div>
1778 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1779 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1780 matches a pattern if removing any number of the final pathname
1781 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1782 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1783 </dd>
1784 <dt class="hdlist1">
1785 --skip-to=&lt;file&gt;
1786 </dt>
1787 <dt class="hdlist1">
1788 --rotate-to=&lt;file&gt;
1789 </dt>
1790 <dd>
1792 Discard the files before the named &lt;file&gt; from the output
1793 (i.e. <em>skip to</em>), or move them to the end of the output
1794 (i.e. <em>rotate to</em>). These were invented primarily for use
1795 of the <code>git difftool</code> command, and may not be very useful
1796 otherwise.
1797 </p>
1798 </dd>
1799 <dt class="hdlist1">
1801 </dt>
1802 <dd>
1804 Swap two inputs; that is, show differences from index or
1805 on-disk file to tree contents.
1806 </p>
1807 </dd>
1808 <dt class="hdlist1">
1809 --relative[=&lt;path&gt;]
1810 </dt>
1811 <dt class="hdlist1">
1812 --no-relative
1813 </dt>
1814 <dd>
1816 When run from a subdirectory of the project, it can be
1817 told to exclude changes outside the directory and show
1818 pathnames relative to it with this option. When you are
1819 not in a subdirectory (e.g. in a bare repository), you
1820 can name which subdirectory to make the output relative
1821 to by giving a &lt;path&gt; as an argument.
1822 <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config
1823 option and previous <code>--relative</code>.
1824 </p>
1825 </dd>
1826 <dt class="hdlist1">
1828 </dt>
1829 <dt class="hdlist1">
1830 --text
1831 </dt>
1832 <dd>
1834 Treat all files as text.
1835 </p>
1836 </dd>
1837 <dt class="hdlist1">
1838 --ignore-cr-at-eol
1839 </dt>
1840 <dd>
1842 Ignore carriage-return at the end of line when doing a comparison.
1843 </p>
1844 </dd>
1845 <dt class="hdlist1">
1846 --ignore-space-at-eol
1847 </dt>
1848 <dd>
1850 Ignore changes in whitespace at EOL.
1851 </p>
1852 </dd>
1853 <dt class="hdlist1">
1855 </dt>
1856 <dt class="hdlist1">
1857 --ignore-space-change
1858 </dt>
1859 <dd>
1861 Ignore changes in amount of whitespace. This ignores whitespace
1862 at line end, and considers all other sequences of one or
1863 more whitespace characters to be equivalent.
1864 </p>
1865 </dd>
1866 <dt class="hdlist1">
1868 </dt>
1869 <dt class="hdlist1">
1870 --ignore-all-space
1871 </dt>
1872 <dd>
1874 Ignore whitespace when comparing lines. This ignores
1875 differences even if one line has whitespace where the other
1876 line has none.
1877 </p>
1878 </dd>
1879 <dt class="hdlist1">
1880 --ignore-blank-lines
1881 </dt>
1882 <dd>
1884 Ignore changes whose lines are all blank.
1885 </p>
1886 </dd>
1887 <dt class="hdlist1">
1888 -I&lt;regex&gt;
1889 </dt>
1890 <dt class="hdlist1">
1891 --ignore-matching-lines=&lt;regex&gt;
1892 </dt>
1893 <dd>
1895 Ignore changes whose all lines match &lt;regex&gt;. This option may
1896 be specified more than once.
1897 </p>
1898 </dd>
1899 <dt class="hdlist1">
1900 --inter-hunk-context=&lt;lines&gt;
1901 </dt>
1902 <dd>
1904 Show the context between diff hunks, up to the specified number
1905 of lines, thereby fusing hunks that are close to each other.
1906 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
1907 is unset.
1908 </p>
1909 </dd>
1910 <dt class="hdlist1">
1912 </dt>
1913 <dt class="hdlist1">
1914 --function-context
1915 </dt>
1916 <dd>
1918 Show whole function as context lines for each change.
1919 The function names are determined in the same way as
1920 <code>git diff</code> works out patch hunk headers (see <em>Defining a
1921 custom hunk-header</em> in <a href="gitattributes.html">gitattributes(5)</a>).
1922 </p>
1923 </dd>
1924 <dt class="hdlist1">
1925 --exit-code
1926 </dt>
1927 <dd>
1929 Make the program exit with codes similar to diff(1).
1930 That is, it exits with 1 if there were differences and
1931 0 means no differences.
1932 </p>
1933 </dd>
1934 <dt class="hdlist1">
1935 --quiet
1936 </dt>
1937 <dd>
1939 Disable all output of the program. Implies <code>--exit-code</code>.
1940 </p>
1941 </dd>
1942 <dt class="hdlist1">
1943 --ext-diff
1944 </dt>
1945 <dd>
1947 Allow an external diff helper to be executed. If you set an
1948 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1949 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1950 </p>
1951 </dd>
1952 <dt class="hdlist1">
1953 --no-ext-diff
1954 </dt>
1955 <dd>
1957 Disallow external diff drivers.
1958 </p>
1959 </dd>
1960 <dt class="hdlist1">
1961 --textconv
1962 </dt>
1963 <dt class="hdlist1">
1964 --no-textconv
1965 </dt>
1966 <dd>
1968 Allow (or disallow) external text conversion filters to be run
1969 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1970 details. Because textconv filters are typically a one-way
1971 conversion, the resulting diff is suitable for human
1972 consumption, but cannot be applied. For this reason, textconv
1973 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1974 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1975 diff plumbing commands.
1976 </p>
1977 </dd>
1978 <dt class="hdlist1">
1979 --ignore-submodules[=&lt;when&gt;]
1980 </dt>
1981 <dd>
1983 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1984 either "none", "untracked", "dirty" or "all", which is the default.
1985 Using "none" will consider the submodule modified when it either contains
1986 untracked or modified files or its HEAD differs from the commit recorded
1987 in the superproject and can be used to override any settings of the
1988 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1989 "untracked" is used submodules are not considered dirty when they only
1990 contain untracked content (but they are still scanned for modified
1991 content). Using "dirty" ignores all changes to the work tree of submodules,
1992 only changes to the commits stored in the superproject are shown (this was
1993 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1994 </p>
1995 </dd>
1996 <dt class="hdlist1">
1997 --src-prefix=&lt;prefix&gt;
1998 </dt>
1999 <dd>
2001 Show the given source prefix instead of "a/".
2002 </p>
2003 </dd>
2004 <dt class="hdlist1">
2005 --dst-prefix=&lt;prefix&gt;
2006 </dt>
2007 <dd>
2009 Show the given destination prefix instead of "b/".
2010 </p>
2011 </dd>
2012 <dt class="hdlist1">
2013 --no-prefix
2014 </dt>
2015 <dd>
2017 Do not show any source or destination prefix.
2018 </p>
2019 </dd>
2020 <dt class="hdlist1">
2021 --default-prefix
2022 </dt>
2023 <dd>
2025 Use the default source and destination prefixes ("a/" and "b/").
2026 This is usually the default already, but may be used to override
2027 config such as <code>diff.noprefix</code>.
2028 </p>
2029 </dd>
2030 <dt class="hdlist1">
2031 --line-prefix=&lt;prefix&gt;
2032 </dt>
2033 <dd>
2035 Prepend an additional prefix to every line of output.
2036 </p>
2037 </dd>
2038 <dt class="hdlist1">
2039 --ita-invisible-in-index
2040 </dt>
2041 <dd>
2043 By default entries added by "git add -N" appear as an existing
2044 empty file in "git diff" and a new file in "git diff --cached".
2045 This option makes the entry appear as a new file in "git diff"
2046 and non-existent in "git diff --cached". This option could be
2047 reverted with <code>--ita-visible-in-index</code>. Both options are
2048 experimental and could be removed in future.
2049 </p>
2050 </dd>
2051 </dl></div>
2052 <div class="paragraph"><p>For more detailed explanation on these common options, see also
2053 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
2054 <div class="dlist"><dl>
2055 <dt class="hdlist1">
2056 -1 --base
2057 </dt>
2058 <dt class="hdlist1">
2059 -2 --ours
2060 </dt>
2061 <dt class="hdlist1">
2062 -3 --theirs
2063 </dt>
2064 <dt class="hdlist1">
2066 </dt>
2067 <dd>
2069 Diff against the "base" version, "our branch" or "their
2070 branch" respectively. With these options, diffs for
2071 merged entries are not shown.
2072 </p>
2073 <div class="paragraph"><p>The default is to diff against our branch (-2) and the
2074 cleanly resolved paths. The option -0 can be given to
2075 omit diff output for unmerged entries and just show "Unmerged".</p></div>
2076 </dd>
2077 <dt class="hdlist1">
2079 </dt>
2080 <dt class="hdlist1">
2081 --cc
2082 </dt>
2083 <dd>
2085 This compares stage 2 (our branch), stage 3 (their
2086 branch) and the working tree file and outputs a combined
2087 diff, similar to the way <em>diff-tree</em> shows a merge
2088 commit with these flags.
2089 </p>
2090 </dd>
2091 <dt class="hdlist1">
2093 </dt>
2094 <dd>
2096 Remain silent even on nonexistent files
2097 </p>
2098 </dd>
2099 </dl></div>
2100 </div>
2101 </div>
2102 <div class="sect1">
2103 <h2 id="_raw_output_format">Raw output format</h2>
2104 <div class="sectionbody">
2105 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
2106 "git-diff-files" and "git diff --raw" are very similar.</p></div>
2107 <div class="paragraph"><p>These commands all compare two sets of things; what is
2108 compared differs:</p></div>
2109 <div class="dlist"><dl>
2110 <dt class="hdlist1">
2111 git-diff-index &lt;tree-ish&gt;
2112 </dt>
2113 <dd>
2115 compares the &lt;tree-ish&gt; and the files on the filesystem.
2116 </p>
2117 </dd>
2118 <dt class="hdlist1">
2119 git-diff-index --cached &lt;tree-ish&gt;
2120 </dt>
2121 <dd>
2123 compares the &lt;tree-ish&gt; and the index.
2124 </p>
2125 </dd>
2126 <dt class="hdlist1">
2127 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
2128 </dt>
2129 <dd>
2131 compares the trees named by the two arguments.
2132 </p>
2133 </dd>
2134 <dt class="hdlist1">
2135 git-diff-files [&lt;pattern&gt;&#8230;]
2136 </dt>
2137 <dd>
2139 compares the index and the files on the filesystem.
2140 </p>
2141 </dd>
2142 </dl></div>
2143 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
2144 what is being compared. After that, all the commands print one output
2145 line per changed file.</p></div>
2146 <div class="paragraph"><p>An output line is formatted this way:</p></div>
2147 <div class="listingblock">
2148 <div class="content">
2149 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
2150 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
2151 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
2152 create :000000 100644 0000000 1234567 A file4
2153 delete :100644 000000 1234567 0000000 D file5
2154 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2155 </div></div>
2156 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2157 <div class="olist arabic"><ol class="arabic">
2158 <li>
2160 a colon.
2161 </p>
2162 </li>
2163 <li>
2165 mode for "src"; 000000 if creation or unmerged.
2166 </p>
2167 </li>
2168 <li>
2170 a space.
2171 </p>
2172 </li>
2173 <li>
2175 mode for "dst"; 000000 if deletion or unmerged.
2176 </p>
2177 </li>
2178 <li>
2180 a space.
2181 </p>
2182 </li>
2183 <li>
2185 sha1 for "src"; 0{40} if creation or unmerged.
2186 </p>
2187 </li>
2188 <li>
2190 a space.
2191 </p>
2192 </li>
2193 <li>
2195 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".
2196 </p>
2197 </li>
2198 <li>
2200 a space.
2201 </p>
2202 </li>
2203 <li>
2205 status, followed by optional "score" number.
2206 </p>
2207 </li>
2208 <li>
2210 a tab or a NUL when <code>-z</code> option is used.
2211 </p>
2212 </li>
2213 <li>
2215 path for "src"
2216 </p>
2217 </li>
2218 <li>
2220 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2221 </p>
2222 </li>
2223 <li>
2225 path for "dst"; only exists for C or R.
2226 </p>
2227 </li>
2228 <li>
2230 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2231 </p>
2232 </li>
2233 </ol></div>
2234 <div class="paragraph"><p>Possible status letters are:</p></div>
2235 <div class="ulist"><ul>
2236 <li>
2238 A: addition of a file
2239 </p>
2240 </li>
2241 <li>
2243 C: copy of a file into a new one
2244 </p>
2245 </li>
2246 <li>
2248 D: deletion of a file
2249 </p>
2250 </li>
2251 <li>
2253 M: modification of the contents or mode of a file
2254 </p>
2255 </li>
2256 <li>
2258 R: renaming of a file
2259 </p>
2260 </li>
2261 <li>
2263 T: change in the type of the file (regular file, symbolic link or submodule)
2264 </p>
2265 </li>
2266 <li>
2268 U: file is unmerged (you must complete the merge before it can
2269 be committed)
2270 </p>
2271 </li>
2272 <li>
2274 X: "unknown" change type (most probably a bug, please report it)
2275 </p>
2276 </li>
2277 </ul></div>
2278 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2279 percentage of similarity between the source and target of the move or
2280 copy). Status letter M may be followed by a score (denoting the
2281 percentage of dissimilarity) for file rewrites.</p></div>
2282 <div class="paragraph"><p>The sha1 for "dst" is shown as all 0&#8217;s if a file on the filesystem
2283 is out of sync with the index.</p></div>
2284 <div class="paragraph"><p>Example:</p></div>
2285 <div class="listingblock">
2286 <div class="content">
2287 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2288 </div></div>
2289 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2290 quoted as explained for the configuration variable <code>core.quotePath</code>
2291 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2292 verbatim and the line is terminated by a NUL byte.</p></div>
2293 </div>
2294 </div>
2295 <div class="sect1">
2296 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2297 <div class="sectionbody">
2298 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2299 can take <code>-c</code> or <code>--cc</code> option
2300 to generate diff output also for merge commits. The output differs
2301 from the format described above in the following way:</p></div>
2302 <div class="olist arabic"><ol class="arabic">
2303 <li>
2305 there is a colon for each parent
2306 </p>
2307 </li>
2308 <li>
2310 there are more "src" modes and "src" sha1
2311 </p>
2312 </li>
2313 <li>
2315 status is concatenated status characters for each parent
2316 </p>
2317 </li>
2318 <li>
2320 no optional "score" number
2321 </p>
2322 </li>
2323 <li>
2325 tab-separated pathname(s) of the file
2326 </p>
2327 </li>
2328 </ol></div>
2329 <div class="paragraph"><p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even
2330 if the file was renamed on any side of history. With
2331 <code>--combined-all-paths</code>, the name of the path in each parent is shown
2332 followed by the name of the path in the merge commit.</p></div>
2333 <div class="paragraph"><p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p></div>
2334 <div class="listingblock">
2335 <div class="content">
2336 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
2337 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
2338 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</code></pre>
2339 </div></div>
2340 <div class="paragraph"><p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p></div>
2341 <div class="listingblock">
2342 <div class="content">
2343 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
2344 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2345 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</code></pre>
2346 </div></div>
2347 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2348 all parents.</p></div>
2349 </div>
2350 </div>
2351 <div class="sect1">
2352 <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2>
2353 <div class="sectionbody">
2354 <div class="paragraph"><p>Running
2355 <a href="git-diff.html">git-diff(1)</a>,
2356 <a href="git-log.html">git-log(1)</a>,
2357 <a href="git-show.html">git-show(1)</a>,
2358 <a href="git-diff-index.html">git-diff-index(1)</a>,
2359 <a href="git-diff-tree.html">git-diff-tree(1)</a>, or
2360 <a href="git-diff-files.html">git-diff-files(1)</a>
2361 with the <code>-p</code> option produces patch text.
2362 You can customize the creation of patch text via the
2363 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables
2364 (see <a href="git.html">git(1)</a>), and the <code>diff</code> attribute (see <a href="gitattributes.html">gitattributes(5)</a>).</p></div>
2365 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2366 diff format:</p></div>
2367 <div class="olist arabic"><ol class="arabic">
2368 <li>
2370 It is preceded with a "git diff" header that looks like this:
2371 </p>
2372 <div class="literalblock">
2373 <div class="content">
2374 <pre><code>diff --git a/file1 b/file2</code></pre>
2375 </div></div>
2376 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2377 involved. Especially, even for a creation or a deletion,
2378 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2379 <div class="paragraph"><p>When rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2380 name of the source file of the rename/copy and the name of
2381 the file that rename/copy produces, respectively.</p></div>
2382 </li>
2383 <li>
2385 It is followed by one or more extended header lines:
2386 </p>
2387 <div class="literalblock">
2388 <div class="content">
2389 <pre><code>old mode &lt;mode&gt;
2390 new mode &lt;mode&gt;
2391 deleted file mode &lt;mode&gt;
2392 new file mode &lt;mode&gt;
2393 copy from &lt;path&gt;
2394 copy to &lt;path&gt;
2395 rename from &lt;path&gt;
2396 rename to &lt;path&gt;
2397 similarity index &lt;number&gt;
2398 dissimilarity index &lt;number&gt;
2399 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</code></pre>
2400 </div></div>
2401 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2402 and file permission bits.</p></div>
2403 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2404 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2405 the dissimilarity index is the percentage of changed lines. It
2406 is a rounded down integer, followed by a percent sign. The
2407 similarity index value of 100% is thus reserved for two equal
2408 files, while 100% dissimilarity means that no line from the old
2409 file made it into the new one.</p></div>
2410 <div class="paragraph"><p>The index line includes the blob object names before and after the change.
2411 The &lt;mode&gt; is included if the file mode does not change; otherwise,
2412 separate lines indicate the old and the new mode.</p></div>
2413 </li>
2414 <li>
2416 Pathnames with "unusual" characters are quoted as explained for
2417 the configuration variable <code>core.quotePath</code> (see
2418 <a href="git-config.html">git-config(1)</a>).
2419 </p>
2420 </li>
2421 <li>
2423 All the <code>file1</code> files in the output refer to files before the
2424 commit, and all the <code>file2</code> files refer to files after the commit.
2425 It is incorrect to apply each change to each file sequentially. For
2426 example, this patch will swap a and b:
2427 </p>
2428 <div class="literalblock">
2429 <div class="content">
2430 <pre><code>diff --git a/a b/b
2431 rename from a
2432 rename to b
2433 diff --git a/b b/a
2434 rename from b
2435 rename to a</code></pre>
2436 </div></div>
2437 </li>
2438 <li>
2440 Hunk headers mention the name of the function to which the hunk
2441 applies. See "Defining a custom hunk-header" in
2442 <a href="gitattributes.html">gitattributes(5)</a> for details of how to tailor to this to
2443 specific languages.
2444 </p>
2445 </li>
2446 </ol></div>
2447 </div>
2448 </div>
2449 <div class="sect1">
2450 <h2 id="_combined_diff_format">Combined diff format</h2>
2451 <div class="sectionbody">
2452 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2453 produce a <em>combined diff</em> when showing a merge. This is the default
2454 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2455 <a href="git-show.html">git-show(1)</a>. Note also that you can give suitable
2456 <code>--diff-merges</code> option to any of these commands to force generation of
2457 diffs in specific format.</p></div>
2458 <div class="paragraph"><p>A "combined diff" format looks like this:</p></div>
2459 <div class="listingblock">
2460 <div class="content">
2461 <pre><code>diff --combined describe.c
2462 index fabadb8,cc95eb0..4866510
2463 --- a/describe.c
2464 +++ b/describe.c
2465 @@@ -98,20 -98,12 +98,20 @@@
2466 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2469 - static void describe(char *arg)
2470 -static void describe(struct commit *cmit, int last_one)
2471 ++static void describe(char *arg, int last_one)
2473 + unsigned char sha1[20];
2474 + struct commit *cmit;
2475 struct commit_list *list;
2476 static int initialized = 0;
2477 struct commit_name *n;
2479 + if (get_sha1(arg, sha1) &lt; 0)
2480 + usage(describe_usage);
2481 + cmit = lookup_commit_reference(sha1);
2482 + if (!cmit)
2483 + usage(describe_usage);
2485 if (!initialized) {
2486 initialized = 1;
2487 for_each_ref(get_name);</code></pre>
2488 </div></div>
2489 <div class="olist arabic"><ol class="arabic">
2490 <li>
2492 It is preceded with a "git diff" header, that looks like
2493 this (when the <code>-c</code> option is used):
2494 </p>
2495 <div class="literalblock">
2496 <div class="content">
2497 <pre><code>diff --combined file</code></pre>
2498 </div></div>
2499 <div class="paragraph"><p>or like this (when the <code>--cc</code> option is used):</p></div>
2500 <div class="literalblock">
2501 <div class="content">
2502 <pre><code>diff --cc file</code></pre>
2503 </div></div>
2504 </li>
2505 <li>
2507 It is followed by one or more extended header lines
2508 (this example shows a merge with two parents):
2509 </p>
2510 <div class="literalblock">
2511 <div class="content">
2512 <pre><code>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
2513 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
2514 new file mode &lt;mode&gt;
2515 deleted file mode &lt;mode&gt;,&lt;mode&gt;</code></pre>
2516 </div></div>
2517 <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
2518 the &lt;mode&gt; is different from the rest. Extended headers with
2519 information about detected contents movement (renames and
2520 copying detection) are designed to work with diff of two
2521 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
2522 </li>
2523 <li>
2525 It is followed by two-line from-file/to-file header
2526 </p>
2527 <div class="literalblock">
2528 <div class="content">
2529 <pre><code>--- a/file
2530 +++ b/file</code></pre>
2531 </div></div>
2532 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
2533 format, <code>/dev/null</code> is used to signal created or deleted
2534 files.</p></div>
2535 <div class="paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2536 two-line from-file/to-file you get a N+1 line from-file/to-file header,
2537 where N is the number of parents in the merge commit</p></div>
2538 <div class="literalblock">
2539 <div class="content">
2540 <pre><code>--- a/file
2541 --- a/file
2542 --- a/file
2543 +++ b/file</code></pre>
2544 </div></div>
2545 <div class="paragraph"><p>This extended format can be useful if rename or copy detection is
2546 active, to allow you to see the original name of the file in different
2547 parents.</p></div>
2548 </li>
2549 <li>
2551 Chunk header format is modified to prevent people from
2552 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2553 was created for review of merge commit changes, and was not
2554 meant to be applied. The change is similar to the change in the
2555 extended <em>index</em> header:
2556 </p>
2557 <div class="literalblock">
2558 <div class="content">
2559 <pre><code>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</code></pre>
2560 </div></div>
2561 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2562 header for combined diff format.</p></div>
2563 </li>
2564 </ol></div>
2565 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2566 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
2567 added to B), or <code>" "</code> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
2568 compares two or more files file1, file2,&#8230; with one file X, and
2569 shows how X differs from each of fileN. One column for each of
2570 fileN is prepended to the output line to note how X&#8217;s line is
2571 different from it.</p></div>
2572 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2573 fileN but it does not appear in the result. A <code>+</code> character
2574 in the column N means that the line appears in the result,
2575 and fileN does not have that line (in other words, the line was
2576 added, from the point of view of that parent).</p></div>
2577 <div class="paragraph"><p>In the above example output, the function signature was changed
2578 from both files (hence two <code>-</code> removals from both file1 and
2579 file2, plus <code>++</code> to mean one line that was added does not appear
2580 in either file1 or file2). Also eight other lines are the same
2581 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2582 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2583 merge commit with the merge result (i.e. file1..fileN are the
2584 parents). When shown by <code>git diff-files -c</code>, it compares the
2585 two unresolved merge parents with the working tree file
2586 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2587 "their version").</p></div>
2588 </div>
2589 </div>
2590 <div class="sect1">
2591 <h2 id="_other_diff_formats">other diff formats</h2>
2592 <div class="sectionbody">
2593 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2594 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2595 output. These options can be combined with other options, such as
2596 <code>-p</code>, and are meant for human consumption.</p></div>
2597 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2598 formats the pathnames compactly by combining common prefix and suffix of
2599 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2600 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2601 <div class="listingblock">
2602 <div class="content">
2603 <pre><code>arch/{i386 =&gt; x86}/Makefile | 4 +--</code></pre>
2604 </div></div>
2605 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2606 for easier machine consumption. An entry in <code>--numstat</code> output looks
2607 like this:</p></div>
2608 <div class="listingblock">
2609 <div class="content">
2610 <pre><code>1 2 README
2611 3 1 arch/{i386 =&gt; x86}/Makefile</code></pre>
2612 </div></div>
2613 <div class="paragraph"><p>That is, from left to right:</p></div>
2614 <div class="olist arabic"><ol class="arabic">
2615 <li>
2617 the number of added lines;
2618 </p>
2619 </li>
2620 <li>
2622 a tab;
2623 </p>
2624 </li>
2625 <li>
2627 the number of deleted lines;
2628 </p>
2629 </li>
2630 <li>
2632 a tab;
2633 </p>
2634 </li>
2635 <li>
2637 pathname (possibly with rename/copy information);
2638 </p>
2639 </li>
2640 <li>
2642 a newline.
2643 </p>
2644 </li>
2645 </ol></div>
2646 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2647 <div class="listingblock">
2648 <div class="content">
2649 <pre><code>1 2 README NUL
2650 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2651 </div></div>
2652 <div class="paragraph"><p>That is:</p></div>
2653 <div class="olist arabic"><ol class="arabic">
2654 <li>
2656 the number of added lines;
2657 </p>
2658 </li>
2659 <li>
2661 a tab;
2662 </p>
2663 </li>
2664 <li>
2666 the number of deleted lines;
2667 </p>
2668 </li>
2669 <li>
2671 a tab;
2672 </p>
2673 </li>
2674 <li>
2676 a NUL (only exists if renamed/copied);
2677 </p>
2678 </li>
2679 <li>
2681 pathname in preimage;
2682 </p>
2683 </li>
2684 <li>
2686 a NUL (only exists if renamed/copied);
2687 </p>
2688 </li>
2689 <li>
2691 pathname in postimage (only exists if renamed/copied);
2692 </p>
2693 </li>
2694 <li>
2696 a NUL.
2697 </p>
2698 </li>
2699 </ol></div>
2700 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2701 scripts that read the output to tell if the current record being read is
2702 a single-path record or a rename/copy record without reading ahead.
2703 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2704 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2705 </div>
2706 </div>
2707 <div class="sect1">
2708 <h2 id="_git">GIT</h2>
2709 <div class="sectionbody">
2710 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2711 </div>
2712 </div>
2713 </div>
2714 <div id="footnotes"><hr /></div>
2715 <div id="footer">
2716 <div id="footer-text">
2717 Last updated
2718 2022-10-28 11:53:56 PDT
2719 </div>
2720 </div>
2721 </body>
2722 </html>