Autogenerated HTML docs for v2.42.0-241-g6bdb5
[git-htmldocs.git] / git-diff-index.html
bloba3d6910e97e6952323b11da5aefe4de7ee064786
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>Compares 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 compares 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. The width
969 of the graph part can be limited by using
970 <code>--stat-graph-width=&lt;width&gt;</code> (affects all commands generating
971 a stat graph) or by setting <code>diff.statGraphWidth=&lt;width&gt;</code>
972 (does not affect <code>git format-patch</code>).
973 By giving a third parameter <code>&lt;count&gt;</code>, you can limit the
974 output to the first <code>&lt;count&gt;</code> lines, followed by <code>...</code> if
975 there are more.
976 </p>
977 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=&lt;width&gt;</code>,
978 <code>--stat-name-width=&lt;name-width&gt;</code> and <code>--stat-count=&lt;count&gt;</code>.</p></div>
979 </dd>
980 <dt class="hdlist1">
981 --compact-summary
982 </dt>
983 <dd>
985 Output a condensed summary of extended header information such
986 as file creations or deletions ("new" or "gone", optionally "+l"
987 if it&#8217;s a symlink) and mode changes ("+x" or "-x" for adding
988 or removing executable bit respectively) in diffstat. The
989 information is put between the filename part and the graph
990 part. Implies <code>--stat</code>.
991 </p>
992 </dd>
993 <dt class="hdlist1">
994 --numstat
995 </dt>
996 <dd>
998 Similar to <code>--stat</code>, but shows number of added and
999 deleted lines in decimal notation and pathname without
1000 abbreviation, to make it more machine friendly. For
1001 binary files, outputs two <code>-</code> instead of saying
1002 <code>0 0</code>.
1003 </p>
1004 </dd>
1005 <dt class="hdlist1">
1006 --shortstat
1007 </dt>
1008 <dd>
1010 Output only the last line of the <code>--stat</code> format containing total
1011 number of modified files, as well as number of added and deleted
1012 lines.
1013 </p>
1014 </dd>
1015 <dt class="hdlist1">
1016 -X[&lt;param1,param2,&#8230;&gt;]
1017 </dt>
1018 <dt class="hdlist1">
1019 --dirstat[=&lt;param1,param2,&#8230;&gt;]
1020 </dt>
1021 <dd>
1023 Output the distribution of relative amount of changes for each
1024 sub-directory. The behavior of <code>--dirstat</code> can be customized by
1025 passing it a comma separated list of parameters.
1026 The defaults are controlled by the <code>diff.dirstat</code> configuration
1027 variable (see <a href="git-config.html">git-config(1)</a>).
1028 The following parameters are available:
1029 </p>
1030 <div class="openblock">
1031 <div class="content">
1032 <div class="dlist"><dl>
1033 <dt class="hdlist1">
1034 <code>changes</code>
1035 </dt>
1036 <dd>
1038 Compute the dirstat numbers by counting the lines that have been
1039 removed from the source, or added to the destination. This ignores
1040 the amount of pure code movements within a file. In other words,
1041 rearranging lines in a file is not counted as much as other changes.
1042 This is the default behavior when no parameter is given.
1043 </p>
1044 </dd>
1045 <dt class="hdlist1">
1046 <code>lines</code>
1047 </dt>
1048 <dd>
1050 Compute the dirstat numbers by doing the regular line-based diff
1051 analysis, and summing the removed/added line counts. (For binary
1052 files, count 64-byte chunks instead, since binary files have no
1053 natural concept of lines). This is a more expensive <code>--dirstat</code>
1054 behavior than the <code>changes</code> behavior, but it does count rearranged
1055 lines within a file as much as other changes. The resulting output
1056 is consistent with what you get from the other <code>--*stat</code> options.
1057 </p>
1058 </dd>
1059 <dt class="hdlist1">
1060 <code>files</code>
1061 </dt>
1062 <dd>
1064 Compute the dirstat numbers by counting the number of files changed.
1065 Each changed file counts equally in the dirstat analysis. This is
1066 the computationally cheapest <code>--dirstat</code> behavior, since it does
1067 not have to look at the file contents at all.
1068 </p>
1069 </dd>
1070 <dt class="hdlist1">
1071 <code>cumulative</code>
1072 </dt>
1073 <dd>
1075 Count changes in a child directory for the parent directory as well.
1076 Note that when using <code>cumulative</code>, the sum of the percentages
1077 reported may exceed 100%. The default (non-cumulative) behavior can
1078 be specified with the <code>noncumulative</code> parameter.
1079 </p>
1080 </dd>
1081 <dt class="hdlist1">
1082 &lt;limit&gt;
1083 </dt>
1084 <dd>
1086 An integer parameter specifies a cut-off percent (3% by default).
1087 Directories contributing less than this percentage of the changes
1088 are not shown in the output.
1089 </p>
1090 </dd>
1091 </dl></div>
1092 </div></div>
1093 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1094 directories with less than 10% of the total amount of changed files,
1095 and accumulating child directory counts in the parent directories:
1096 <code>--dirstat=files,10,cumulative</code>.</p></div>
1097 </dd>
1098 <dt class="hdlist1">
1099 --cumulative
1100 </dt>
1101 <dd>
1103 Synonym for --dirstat=cumulative
1104 </p>
1105 </dd>
1106 <dt class="hdlist1">
1107 --dirstat-by-file[=&lt;param1,param2&gt;&#8230;]
1108 </dt>
1109 <dd>
1111 Synonym for --dirstat=files,param1,param2&#8230;
1112 </p>
1113 </dd>
1114 <dt class="hdlist1">
1115 --summary
1116 </dt>
1117 <dd>
1119 Output a condensed summary of extended header information
1120 such as creations, renames and mode changes.
1121 </p>
1122 </dd>
1123 <dt class="hdlist1">
1124 --patch-with-stat
1125 </dt>
1126 <dd>
1128 Synonym for <code>-p --stat</code>.
1129 </p>
1130 </dd>
1131 <dt class="hdlist1">
1133 </dt>
1134 <dd>
1136 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1137 given, do not munge pathnames and use NULs as output field terminators.
1138 </p>
1139 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1140 explained for the configuration variable <code>core.quotePath</code> (see
1141 <a href="git-config.html">git-config(1)</a>).</p></div>
1142 </dd>
1143 <dt class="hdlist1">
1144 --name-only
1145 </dt>
1146 <dd>
1148 Show only names of changed files. The file names are often encoded in UTF-8.
1149 For more information see the discussion about encoding in the <a href="git-log.html">git-log(1)</a>
1150 manual page.
1151 </p>
1152 </dd>
1153 <dt class="hdlist1">
1154 --name-status
1155 </dt>
1156 <dd>
1158 Show only names and status of changed files. See the description
1159 of the <code>--diff-filter</code> option on what the status letters mean.
1160 Just like <code>--name-only</code> the file names are often encoded in UTF-8.
1161 </p>
1162 </dd>
1163 <dt class="hdlist1">
1164 --submodule[=&lt;format&gt;]
1165 </dt>
1166 <dd>
1168 Specify how differences in submodules are shown. When specifying
1169 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1170 shows the names of the commits at the beginning and end of the range.
1171 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1172 format is used. This format lists the commits in the range like
1173 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1174 is specified, the <em>diff</em> format is used. This format shows an
1175 inline diff of the changes in the submodule contents between the
1176 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1177 if the config option is unset.
1178 </p>
1179 </dd>
1180 <dt class="hdlist1">
1181 --color[=&lt;when&gt;]
1182 </dt>
1183 <dd>
1185 Show colored diff.
1186 <code>--color</code> (i.e. without <em>=&lt;when&gt;</em>) is the same as <code>--color=always</code>.
1187 <em>&lt;when&gt;</em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1188 </p>
1189 </dd>
1190 <dt class="hdlist1">
1191 --no-color
1192 </dt>
1193 <dd>
1195 Turn off colored diff.
1196 It is the same as <code>--color=never</code>.
1197 </p>
1198 </dd>
1199 <dt class="hdlist1">
1200 --color-moved[=&lt;mode&gt;]
1201 </dt>
1202 <dd>
1204 Moved lines of code are colored differently.
1205 The &lt;mode&gt; defaults to <em>no</em> if the option is not given
1206 and to <em>zebra</em> if the option with no mode is given.
1207 The mode must be one of:
1208 </p>
1209 <div class="openblock">
1210 <div class="content">
1211 <div class="dlist"><dl>
1212 <dt class="hdlist1">
1214 </dt>
1215 <dd>
1217 Moved lines are not highlighted.
1218 </p>
1219 </dd>
1220 <dt class="hdlist1">
1221 default
1222 </dt>
1223 <dd>
1225 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1226 in the future.
1227 </p>
1228 </dd>
1229 <dt class="hdlist1">
1230 plain
1231 </dt>
1232 <dd>
1234 Any line that is added in one location and was removed
1235 in another location will be colored with <em>color.diff.newMoved</em>.
1236 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1237 that are added somewhere else in the diff. This mode picks up any
1238 moved line, but it is not very useful in a review to determine
1239 if a block of code was moved without permutation.
1240 </p>
1241 </dd>
1242 <dt class="hdlist1">
1243 blocks
1244 </dt>
1245 <dd>
1247 Blocks of moved text of at least 20 alphanumeric characters
1248 are detected greedily. The detected blocks are
1249 painted using either the <em>color.diff.{old,new}Moved</em> color.
1250 Adjacent blocks cannot be told apart.
1251 </p>
1252 </dd>
1253 <dt class="hdlist1">
1254 zebra
1255 </dt>
1256 <dd>
1258 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1259 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1260 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1261 the two colors indicates that a new block was detected.
1262 </p>
1263 </dd>
1264 <dt class="hdlist1">
1265 dimmed-zebra
1266 </dt>
1267 <dd>
1269 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1270 of moved code is performed. The bordering lines of two adjacent
1271 blocks are considered interesting, the rest is uninteresting.
1272 <code>dimmed_zebra</code> is a deprecated synonym.
1273 </p>
1274 </dd>
1275 </dl></div>
1276 </div></div>
1277 </dd>
1278 <dt class="hdlist1">
1279 --no-color-moved
1280 </dt>
1281 <dd>
1283 Turn off move detection. This can be used to override configuration
1284 settings. It is the same as <code>--color-moved=no</code>.
1285 </p>
1286 </dd>
1287 <dt class="hdlist1">
1288 --color-moved-ws=&lt;modes&gt;
1289 </dt>
1290 <dd>
1292 This configures how whitespace is ignored when performing the
1293 move detection for <code>--color-moved</code>.
1294 These modes can be given as a comma separated list:
1295 </p>
1296 <div class="openblock">
1297 <div class="content">
1298 <div class="dlist"><dl>
1299 <dt class="hdlist1">
1301 </dt>
1302 <dd>
1304 Do not ignore whitespace when performing move detection.
1305 </p>
1306 </dd>
1307 <dt class="hdlist1">
1308 ignore-space-at-eol
1309 </dt>
1310 <dd>
1312 Ignore changes in whitespace at EOL.
1313 </p>
1314 </dd>
1315 <dt class="hdlist1">
1316 ignore-space-change
1317 </dt>
1318 <dd>
1320 Ignore changes in amount of whitespace. This ignores whitespace
1321 at line end, and considers all other sequences of one or
1322 more whitespace characters to be equivalent.
1323 </p>
1324 </dd>
1325 <dt class="hdlist1">
1326 ignore-all-space
1327 </dt>
1328 <dd>
1330 Ignore whitespace when comparing lines. This ignores differences
1331 even if one line has whitespace where the other line has none.
1332 </p>
1333 </dd>
1334 <dt class="hdlist1">
1335 allow-indentation-change
1336 </dt>
1337 <dd>
1339 Initially ignore any whitespace in the move detection, then
1340 group the moved code blocks only into a block if the change in
1341 whitespace is the same per line. This is incompatible with the
1342 other modes.
1343 </p>
1344 </dd>
1345 </dl></div>
1346 </div></div>
1347 </dd>
1348 <dt class="hdlist1">
1349 --no-color-moved-ws
1350 </dt>
1351 <dd>
1353 Do not ignore whitespace when performing move detection. This can be
1354 used to override configuration settings. It is the same as
1355 <code>--color-moved-ws=no</code>.
1356 </p>
1357 </dd>
1358 <dt class="hdlist1">
1359 --word-diff[=&lt;mode&gt;]
1360 </dt>
1361 <dd>
1363 Show a word diff, using the &lt;mode&gt; to delimit changed words.
1364 By default, words are delimited by whitespace; see
1365 <code>--word-diff-regex</code> below. The &lt;mode&gt; defaults to <em>plain</em>, and
1366 must be one of:
1367 </p>
1368 <div class="openblock">
1369 <div class="content">
1370 <div class="dlist"><dl>
1371 <dt class="hdlist1">
1372 color
1373 </dt>
1374 <dd>
1376 Highlight changed words using only colors. Implies <code>--color</code>.
1377 </p>
1378 </dd>
1379 <dt class="hdlist1">
1380 plain
1381 </dt>
1382 <dd>
1384 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1385 attempts to escape the delimiters if they appear in the input,
1386 so the output may be ambiguous.
1387 </p>
1388 </dd>
1389 <dt class="hdlist1">
1390 porcelain
1391 </dt>
1392 <dd>
1394 Use a special line-based format intended for script
1395 consumption. Added/removed/unchanged runs are printed in the
1396 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1397 character at the beginning of the line and extending to the
1398 end of the line. Newlines in the input are represented by a
1399 tilde <code>~</code> on a line of its own.
1400 </p>
1401 </dd>
1402 <dt class="hdlist1">
1403 none
1404 </dt>
1405 <dd>
1407 Disable word diff again.
1408 </p>
1409 </dd>
1410 </dl></div>
1411 </div></div>
1412 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1413 highlight the changed parts in all modes if enabled.</p></div>
1414 </dd>
1415 <dt class="hdlist1">
1416 --word-diff-regex=&lt;regex&gt;
1417 </dt>
1418 <dd>
1420 Use &lt;regex&gt; to decide what a word is, instead of considering
1421 runs of non-whitespace to be a word. Also implies
1422 <code>--word-diff</code> unless it was already enabled.
1423 </p>
1424 <div class="paragraph"><p>Every non-overlapping match of the
1425 &lt;regex&gt; is considered a word. Anything between these matches is
1426 considered whitespace and ignored(!) for the purposes of finding
1427 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1428 expression to make sure that it matches all non-whitespace characters.
1429 A match that contains a newline is silently truncated(!) at the
1430 newline.</p></div>
1431 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1432 and, correspondingly, show differences character by character.</p></div>
1433 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1434 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1435 overrides any diff driver or configuration setting. Diff drivers
1436 override configuration settings.</p></div>
1437 </dd>
1438 <dt class="hdlist1">
1439 --color-words[=&lt;regex&gt;]
1440 </dt>
1441 <dd>
1443 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1444 specified) <code>--word-diff-regex=&lt;regex&gt;</code>.
1445 </p>
1446 </dd>
1447 <dt class="hdlist1">
1448 --no-renames
1449 </dt>
1450 <dd>
1452 Turn off rename detection, even when the configuration
1453 file gives the default to do so.
1454 </p>
1455 </dd>
1456 <dt class="hdlist1">
1457 --[no-]rename-empty
1458 </dt>
1459 <dd>
1461 Whether to use empty blobs as rename source.
1462 </p>
1463 </dd>
1464 <dt class="hdlist1">
1465 --check
1466 </dt>
1467 <dd>
1469 Warn if changes introduce conflict markers or whitespace errors.
1470 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1471 configuration. By default, trailing whitespaces (including
1472 lines that consist solely of whitespaces) and a space character
1473 that is immediately followed by a tab character inside the
1474 initial indent of the line are considered whitespace errors.
1475 Exits with non-zero status if problems are found. Not compatible
1476 with --exit-code.
1477 </p>
1478 </dd>
1479 <dt class="hdlist1">
1480 --ws-error-highlight=&lt;kind&gt;
1481 </dt>
1482 <dd>
1484 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1485 lines of the diff. Multiple values are separated by comma,
1486 <code>none</code> resets previous values, <code>default</code> reset the list to
1487 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1488 this option is not given, and the configuration variable
1489 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1490 <code>new</code> lines are highlighted. The whitespace errors are colored
1491 with <code>color.diff.whitespace</code>.
1492 </p>
1493 </dd>
1494 <dt class="hdlist1">
1495 --full-index
1496 </dt>
1497 <dd>
1499 Instead of the first handful of characters, show the full
1500 pre- and post-image blob object names on the "index"
1501 line when generating patch format output.
1502 </p>
1503 </dd>
1504 <dt class="hdlist1">
1505 --binary
1506 </dt>
1507 <dd>
1509 In addition to <code>--full-index</code>, output a binary diff that
1510 can be applied with <code>git-apply</code>.
1511 Implies <code>--patch</code>.
1512 </p>
1513 </dd>
1514 <dt class="hdlist1">
1515 --abbrev[=&lt;n&gt;]
1516 </dt>
1517 <dd>
1519 Instead of showing the full 40-byte hexadecimal object
1520 name in diff-raw format output and diff-tree header
1521 lines, show the shortest prefix that is at least <em>&lt;n&gt;</em>
1522 hexdigits long that uniquely refers the object.
1523 In diff-patch output format, <code>--full-index</code> takes higher
1524 precedence, i.e. if <code>--full-index</code> is specified, full blob
1525 names will be shown regardless of <code>--abbrev</code>.
1526 Non default number of digits can be specified with <code>--abbrev=&lt;n&gt;</code>.
1527 </p>
1528 </dd>
1529 <dt class="hdlist1">
1530 -B[&lt;n&gt;][/&lt;m&gt;]
1531 </dt>
1532 <dt class="hdlist1">
1533 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1534 </dt>
1535 <dd>
1537 Break complete rewrite changes into pairs of delete and
1538 create. This serves two purposes:
1539 </p>
1540 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1541 not as a series of deletion and insertion mixed together with a very
1542 few lines that happen to match textually as the context, but as a
1543 single deletion of everything old followed by a single insertion of
1544 everything new, and the number <code>m</code> controls this aspect of the -B
1545 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1546 original should remain in the result for Git to consider it a total
1547 rewrite (i.e. otherwise the resulting patch will be a series of
1548 deletion and insertion mixed together with context lines).</p></div>
1549 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1550 source of a rename (usually -M only considers a file that disappeared
1551 as the source of a rename), and the number <code>n</code> controls this aspect of
1552 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1553 addition and deletion compared to 20% or more of the file&#8217;s size are
1554 eligible for being picked up as a possible source of a rename to
1555 another file.</p></div>
1556 </dd>
1557 <dt class="hdlist1">
1558 -M[&lt;n&gt;]
1559 </dt>
1560 <dt class="hdlist1">
1561 --find-renames[=&lt;n&gt;]
1562 </dt>
1563 <dd>
1565 Detect renames.
1566 If <code>n</code> is specified, it is a threshold on the similarity
1567 index (i.e. amount of addition/deletions compared to the
1568 file&#8217;s size). For example, <code>-M90%</code> means Git should consider a
1569 delete/add pair to be a rename if more than 90% of the file
1570 hasn&#8217;t changed. Without a <code>%</code> sign, the number is to be read as
1571 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1572 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1573 the same as <code>-M5%</code>. To limit detection to exact renames, use
1574 <code>-M100%</code>. The default similarity index is 50%.
1575 </p>
1576 </dd>
1577 <dt class="hdlist1">
1578 -C[&lt;n&gt;]
1579 </dt>
1580 <dt class="hdlist1">
1581 --find-copies[=&lt;n&gt;]
1582 </dt>
1583 <dd>
1585 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1586 If <code>n</code> is specified, it has the same meaning as for <code>-M&lt;n&gt;</code>.
1587 </p>
1588 </dd>
1589 <dt class="hdlist1">
1590 --find-copies-harder
1591 </dt>
1592 <dd>
1594 For performance reasons, by default, <code>-C</code> option finds copies only
1595 if the original file of the copy was modified in the same
1596 changeset. This flag makes the command
1597 inspect unmodified files as candidates for the source of
1598 copy. This is a very expensive operation for large
1599 projects, so use it with caution. Giving more than one
1600 <code>-C</code> option has the same effect.
1601 </p>
1602 </dd>
1603 <dt class="hdlist1">
1605 </dt>
1606 <dt class="hdlist1">
1607 --irreversible-delete
1608 </dt>
1609 <dd>
1611 Omit the preimage for deletes, i.e. print only the header but not
1612 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1613 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1614 solely for people who want to just concentrate on reviewing the
1615 text after the change. In addition, the output obviously lacks
1616 enough information to apply such a patch in reverse, even manually,
1617 hence the name of the option.
1618 </p>
1619 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1620 of a delete/create pair.</p></div>
1621 </dd>
1622 <dt class="hdlist1">
1623 -l&lt;num&gt;
1624 </dt>
1625 <dd>
1627 The <code>-M</code> and <code>-C</code> options involve some preliminary steps that
1628 can detect subsets of renames/copies cheaply, followed by an
1629 exhaustive fallback portion that compares all remaining
1630 unpaired destinations to all relevant sources. (For renames,
1631 only remaining unpaired sources are relevant; for copies, all
1632 original sources are relevant.) For N sources and
1633 destinations, this exhaustive check is O(N^2). This option
1634 prevents the exhaustive portion of rename/copy detection from
1635 running if the number of source/destination files involved
1636 exceeds the specified number. Defaults to diff.renameLimit.
1637 Note that a value of 0 is treated as unlimited.
1638 </p>
1639 </dd>
1640 <dt class="hdlist1">
1641 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1642 </dt>
1643 <dd>
1645 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1646 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1647 type (i.e. regular file, symlink, submodule, &#8230;) changed (<code>T</code>),
1648 are Unmerged (<code>U</code>), are
1649 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1650 Any combination of the filter characters (including none) can be used.
1651 When <code>*</code> (All-or-none) is added to the combination, all
1652 paths are selected if there is any file that matches
1653 other criteria in the comparison; if there is no file
1654 that matches other criteria, nothing is selected.
1655 </p>
1656 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1657 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1658 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1659 renamed entries cannot appear if detection for those types is disabled.</p></div>
1660 </dd>
1661 <dt class="hdlist1">
1662 -S&lt;string&gt;
1663 </dt>
1664 <dd>
1666 Look for differences that change the number of occurrences of
1667 the specified string (i.e. addition/deletion) in a file.
1668 Intended for the scripter&#8217;s use.
1669 </p>
1670 <div class="paragraph"><p>It is useful when you&#8217;re looking for an exact block of code (like a
1671 struct), and want to know the history of that block since it first
1672 came into being: use the feature iteratively to feed the interesting
1673 block in the preimage back into <code>-S</code>, and keep going until you get the
1674 very first version of the block.</p></div>
1675 <div class="paragraph"><p>Binary files are searched as well.</p></div>
1676 </dd>
1677 <dt class="hdlist1">
1678 -G&lt;regex&gt;
1679 </dt>
1680 <dd>
1682 Look for differences whose patch text contains added/removed
1683 lines that match &lt;regex&gt;.
1684 </p>
1685 <div class="paragraph"><p>To illustrate the difference between <code>-S&lt;regex&gt; --pickaxe-regex</code> and
1686 <code>-G&lt;regex&gt;</code>, consider a commit with the following diff in the same
1687 file:</p></div>
1688 <div class="listingblock">
1689 <div class="content">
1690 <pre><code>+ return frotz(nitfol, two-&gt;ptr, 1, 0);
1692 - hit = frotz(nitfol, mf2.ptr, 1, 0);</code></pre>
1693 </div></div>
1694 <div class="paragraph"><p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log
1695 -S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of
1696 occurrences of that string did not change).</p></div>
1697 <div class="paragraph"><p>Unless <code>--text</code> is supplied patches of binary files without a textconv
1698 filter will be ignored.</p></div>
1699 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1700 information.</p></div>
1701 </dd>
1702 <dt class="hdlist1">
1703 --find-object=&lt;object-id&gt;
1704 </dt>
1705 <dd>
1707 Look for differences that change the number of occurrences of
1708 the specified object. Similar to <code>-S</code>, just the argument is different
1709 in that it doesn&#8217;t search for a specific string but for a specific
1710 object id.
1711 </p>
1712 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1713 <code>git-log</code> to also find trees.</p></div>
1714 </dd>
1715 <dt class="hdlist1">
1716 --pickaxe-all
1717 </dt>
1718 <dd>
1720 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1721 changeset, not just the files that contain the change
1722 in &lt;string&gt;.
1723 </p>
1724 </dd>
1725 <dt class="hdlist1">
1726 --pickaxe-regex
1727 </dt>
1728 <dd>
1730 Treat the &lt;string&gt; given to <code>-S</code> as an extended POSIX regular
1731 expression to match.
1732 </p>
1733 </dd>
1734 <dt class="hdlist1">
1735 -O&lt;orderfile&gt;
1736 </dt>
1737 <dd>
1739 Control the order in which files appear in the output.
1740 This overrides the <code>diff.orderFile</code> configuration variable
1741 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1742 use <code>-O/dev/null</code>.
1743 </p>
1744 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1745 &lt;orderfile&gt;.
1746 All files with pathnames that match the first pattern are output
1747 first, all files with pathnames that match the second pattern (but not
1748 the first) are output next, and so on.
1749 All files with pathnames that do not match any pattern are output
1750 last, as if there was an implicit match-all pattern at the end of the
1751 file.
1752 If multiple pathnames have the same rank (they match the same pattern
1753 but no earlier patterns), their output order relative to each other is
1754 the normal order.</p></div>
1755 <div class="paragraph"><p>&lt;orderfile&gt; is parsed as follows:</p></div>
1756 <div class="openblock">
1757 <div class="content">
1758 <div class="ulist"><ul>
1759 <li>
1761 Blank lines are ignored, so they can be used as separators for
1762 readability.
1763 </p>
1764 </li>
1765 <li>
1767 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1768 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1769 pattern if it starts with a hash.
1770 </p>
1771 </li>
1772 <li>
1774 Each other line contains a single pattern.
1775 </p>
1776 </li>
1777 </ul></div>
1778 </div></div>
1779 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1780 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1781 matches a pattern if removing any number of the final pathname
1782 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1783 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1784 </dd>
1785 <dt class="hdlist1">
1786 --skip-to=&lt;file&gt;
1787 </dt>
1788 <dt class="hdlist1">
1789 --rotate-to=&lt;file&gt;
1790 </dt>
1791 <dd>
1793 Discard the files before the named &lt;file&gt; from the output
1794 (i.e. <em>skip to</em>), or move them to the end of the output
1795 (i.e. <em>rotate to</em>). These were invented primarily for use
1796 of the <code>git difftool</code> command, and may not be very useful
1797 otherwise.
1798 </p>
1799 </dd>
1800 <dt class="hdlist1">
1802 </dt>
1803 <dd>
1805 Swap two inputs; that is, show differences from index or
1806 on-disk file to tree contents.
1807 </p>
1808 </dd>
1809 <dt class="hdlist1">
1810 --relative[=&lt;path&gt;]
1811 </dt>
1812 <dt class="hdlist1">
1813 --no-relative
1814 </dt>
1815 <dd>
1817 When run from a subdirectory of the project, it can be
1818 told to exclude changes outside the directory and show
1819 pathnames relative to it with this option. When you are
1820 not in a subdirectory (e.g. in a bare repository), you
1821 can name which subdirectory to make the output relative
1822 to by giving a &lt;path&gt; as an argument.
1823 <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config
1824 option and previous <code>--relative</code>.
1825 </p>
1826 </dd>
1827 <dt class="hdlist1">
1829 </dt>
1830 <dt class="hdlist1">
1831 --text
1832 </dt>
1833 <dd>
1835 Treat all files as text.
1836 </p>
1837 </dd>
1838 <dt class="hdlist1">
1839 --ignore-cr-at-eol
1840 </dt>
1841 <dd>
1843 Ignore carriage-return at the end of line when doing a comparison.
1844 </p>
1845 </dd>
1846 <dt class="hdlist1">
1847 --ignore-space-at-eol
1848 </dt>
1849 <dd>
1851 Ignore changes in whitespace at EOL.
1852 </p>
1853 </dd>
1854 <dt class="hdlist1">
1856 </dt>
1857 <dt class="hdlist1">
1858 --ignore-space-change
1859 </dt>
1860 <dd>
1862 Ignore changes in amount of whitespace. This ignores whitespace
1863 at line end, and considers all other sequences of one or
1864 more whitespace characters to be equivalent.
1865 </p>
1866 </dd>
1867 <dt class="hdlist1">
1869 </dt>
1870 <dt class="hdlist1">
1871 --ignore-all-space
1872 </dt>
1873 <dd>
1875 Ignore whitespace when comparing lines. This ignores
1876 differences even if one line has whitespace where the other
1877 line has none.
1878 </p>
1879 </dd>
1880 <dt class="hdlist1">
1881 --ignore-blank-lines
1882 </dt>
1883 <dd>
1885 Ignore changes whose lines are all blank.
1886 </p>
1887 </dd>
1888 <dt class="hdlist1">
1889 -I&lt;regex&gt;
1890 </dt>
1891 <dt class="hdlist1">
1892 --ignore-matching-lines=&lt;regex&gt;
1893 </dt>
1894 <dd>
1896 Ignore changes whose all lines match &lt;regex&gt;. This option may
1897 be specified more than once.
1898 </p>
1899 </dd>
1900 <dt class="hdlist1">
1901 --inter-hunk-context=&lt;lines&gt;
1902 </dt>
1903 <dd>
1905 Show the context between diff hunks, up to the specified number
1906 of lines, thereby fusing hunks that are close to each other.
1907 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
1908 is unset.
1909 </p>
1910 </dd>
1911 <dt class="hdlist1">
1913 </dt>
1914 <dt class="hdlist1">
1915 --function-context
1916 </dt>
1917 <dd>
1919 Show whole function as context lines for each change.
1920 The function names are determined in the same way as
1921 <code>git diff</code> works out patch hunk headers (see <em>Defining a
1922 custom hunk-header</em> in <a href="gitattributes.html">gitattributes(5)</a>).
1923 </p>
1924 </dd>
1925 <dt class="hdlist1">
1926 --exit-code
1927 </dt>
1928 <dd>
1930 Make the program exit with codes similar to diff(1).
1931 That is, it exits with 1 if there were differences and
1932 0 means no differences.
1933 </p>
1934 </dd>
1935 <dt class="hdlist1">
1936 --quiet
1937 </dt>
1938 <dd>
1940 Disable all output of the program. Implies <code>--exit-code</code>.
1941 </p>
1942 </dd>
1943 <dt class="hdlist1">
1944 --ext-diff
1945 </dt>
1946 <dd>
1948 Allow an external diff helper to be executed. If you set an
1949 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1950 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1951 </p>
1952 </dd>
1953 <dt class="hdlist1">
1954 --no-ext-diff
1955 </dt>
1956 <dd>
1958 Disallow external diff drivers.
1959 </p>
1960 </dd>
1961 <dt class="hdlist1">
1962 --textconv
1963 </dt>
1964 <dt class="hdlist1">
1965 --no-textconv
1966 </dt>
1967 <dd>
1969 Allow (or disallow) external text conversion filters to be run
1970 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1971 details. Because textconv filters are typically a one-way
1972 conversion, the resulting diff is suitable for human
1973 consumption, but cannot be applied. For this reason, textconv
1974 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1975 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1976 diff plumbing commands.
1977 </p>
1978 </dd>
1979 <dt class="hdlist1">
1980 --ignore-submodules[=&lt;when&gt;]
1981 </dt>
1982 <dd>
1984 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1985 either "none", "untracked", "dirty" or "all", which is the default.
1986 Using "none" will consider the submodule modified when it either contains
1987 untracked or modified files or its HEAD differs from the commit recorded
1988 in the superproject and can be used to override any settings of the
1989 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1990 "untracked" is used submodules are not considered dirty when they only
1991 contain untracked content (but they are still scanned for modified
1992 content). Using "dirty" ignores all changes to the work tree of submodules,
1993 only changes to the commits stored in the superproject are shown (this was
1994 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1995 </p>
1996 </dd>
1997 <dt class="hdlist1">
1998 --src-prefix=&lt;prefix&gt;
1999 </dt>
2000 <dd>
2002 Show the given source prefix instead of "a/".
2003 </p>
2004 </dd>
2005 <dt class="hdlist1">
2006 --dst-prefix=&lt;prefix&gt;
2007 </dt>
2008 <dd>
2010 Show the given destination prefix instead of "b/".
2011 </p>
2012 </dd>
2013 <dt class="hdlist1">
2014 --no-prefix
2015 </dt>
2016 <dd>
2018 Do not show any source or destination prefix.
2019 </p>
2020 </dd>
2021 <dt class="hdlist1">
2022 --default-prefix
2023 </dt>
2024 <dd>
2026 Use the default source and destination prefixes ("a/" and "b/").
2027 This is usually the default already, but may be used to override
2028 config such as <code>diff.noprefix</code>.
2029 </p>
2030 </dd>
2031 <dt class="hdlist1">
2032 --line-prefix=&lt;prefix&gt;
2033 </dt>
2034 <dd>
2036 Prepend an additional prefix to every line of output.
2037 </p>
2038 </dd>
2039 <dt class="hdlist1">
2040 --ita-invisible-in-index
2041 </dt>
2042 <dd>
2044 By default entries added by "git add -N" appear as an existing
2045 empty file in "git diff" and a new file in "git diff --cached".
2046 This option makes the entry appear as a new file in "git diff"
2047 and non-existent in "git diff --cached". This option could be
2048 reverted with <code>--ita-visible-in-index</code>. Both options are
2049 experimental and could be removed in future.
2050 </p>
2051 </dd>
2052 </dl></div>
2053 <div class="paragraph"><p>For more detailed explanation on these common options, see also
2054 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
2055 <div class="dlist"><dl>
2056 <dt class="hdlist1">
2057 &lt;tree-ish&gt;
2058 </dt>
2059 <dd>
2061 The id of a tree object to diff against.
2062 </p>
2063 </dd>
2064 <dt class="hdlist1">
2065 --cached
2066 </dt>
2067 <dd>
2069 Do not consider the on-disk file at all.
2070 </p>
2071 </dd>
2072 <dt class="hdlist1">
2073 --merge-base
2074 </dt>
2075 <dd>
2077 Instead of comparing &lt;tree-ish&gt; directly, use the merge base
2078 between &lt;tree-ish&gt; and HEAD instead. &lt;tree-ish&gt; must be a
2079 commit.
2080 </p>
2081 </dd>
2082 <dt class="hdlist1">
2084 </dt>
2085 <dd>
2087 By default, files recorded in the index but not checked
2088 out are reported as deleted. This flag makes
2089 <em>git diff-index</em> say that all non-checked-out files are up
2090 to date.
2091 </p>
2092 </dd>
2093 </dl></div>
2094 </div>
2095 </div>
2096 <div class="sect1">
2097 <h2 id="_raw_output_format">Raw output format</h2>
2098 <div class="sectionbody">
2099 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
2100 "git-diff-files" and "git diff --raw" are very similar.</p></div>
2101 <div class="paragraph"><p>These commands all compare two sets of things; what is
2102 compared differs:</p></div>
2103 <div class="dlist"><dl>
2104 <dt class="hdlist1">
2105 git-diff-index &lt;tree-ish&gt;
2106 </dt>
2107 <dd>
2109 compares the &lt;tree-ish&gt; and the files on the filesystem.
2110 </p>
2111 </dd>
2112 <dt class="hdlist1">
2113 git-diff-index --cached &lt;tree-ish&gt;
2114 </dt>
2115 <dd>
2117 compares the &lt;tree-ish&gt; and the index.
2118 </p>
2119 </dd>
2120 <dt class="hdlist1">
2121 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
2122 </dt>
2123 <dd>
2125 compares the trees named by the two arguments.
2126 </p>
2127 </dd>
2128 <dt class="hdlist1">
2129 git-diff-files [&lt;pattern&gt;&#8230;]
2130 </dt>
2131 <dd>
2133 compares the index and the files on the filesystem.
2134 </p>
2135 </dd>
2136 </dl></div>
2137 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
2138 what is being compared. After that, all the commands print one output
2139 line per changed file.</p></div>
2140 <div class="paragraph"><p>An output line is formatted this way:</p></div>
2141 <div class="listingblock">
2142 <div class="content">
2143 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
2144 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
2145 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
2146 create :000000 100644 0000000 1234567 A file4
2147 delete :100644 000000 1234567 0000000 D file5
2148 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2149 </div></div>
2150 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2151 <div class="olist arabic"><ol class="arabic">
2152 <li>
2154 a colon.
2155 </p>
2156 </li>
2157 <li>
2159 mode for "src"; 000000 if creation or unmerged.
2160 </p>
2161 </li>
2162 <li>
2164 a space.
2165 </p>
2166 </li>
2167 <li>
2169 mode for "dst"; 000000 if deletion or unmerged.
2170 </p>
2171 </li>
2172 <li>
2174 a space.
2175 </p>
2176 </li>
2177 <li>
2179 sha1 for "src"; 0{40} if creation or unmerged.
2180 </p>
2181 </li>
2182 <li>
2184 a space.
2185 </p>
2186 </li>
2187 <li>
2189 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".
2190 </p>
2191 </li>
2192 <li>
2194 a space.
2195 </p>
2196 </li>
2197 <li>
2199 status, followed by optional "score" number.
2200 </p>
2201 </li>
2202 <li>
2204 a tab or a NUL when <code>-z</code> option is used.
2205 </p>
2206 </li>
2207 <li>
2209 path for "src"
2210 </p>
2211 </li>
2212 <li>
2214 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2215 </p>
2216 </li>
2217 <li>
2219 path for "dst"; only exists for C or R.
2220 </p>
2221 </li>
2222 <li>
2224 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2225 </p>
2226 </li>
2227 </ol></div>
2228 <div class="paragraph"><p>Possible status letters are:</p></div>
2229 <div class="ulist"><ul>
2230 <li>
2232 A: addition of a file
2233 </p>
2234 </li>
2235 <li>
2237 C: copy of a file into a new one
2238 </p>
2239 </li>
2240 <li>
2242 D: deletion of a file
2243 </p>
2244 </li>
2245 <li>
2247 M: modification of the contents or mode of a file
2248 </p>
2249 </li>
2250 <li>
2252 R: renaming of a file
2253 </p>
2254 </li>
2255 <li>
2257 T: change in the type of the file (regular file, symbolic link or submodule)
2258 </p>
2259 </li>
2260 <li>
2262 U: file is unmerged (you must complete the merge before it can
2263 be committed)
2264 </p>
2265 </li>
2266 <li>
2268 X: "unknown" change type (most probably a bug, please report it)
2269 </p>
2270 </li>
2271 </ul></div>
2272 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2273 percentage of similarity between the source and target of the move or
2274 copy). Status letter M may be followed by a score (denoting the
2275 percentage of dissimilarity) for file rewrites.</p></div>
2276 <div class="paragraph"><p>The sha1 for "dst" is shown as all 0&#8217;s if a file on the filesystem
2277 is out of sync with the index.</p></div>
2278 <div class="paragraph"><p>Example:</p></div>
2279 <div class="listingblock">
2280 <div class="content">
2281 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2282 </div></div>
2283 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2284 quoted as explained for the configuration variable <code>core.quotePath</code>
2285 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2286 verbatim and the line is terminated by a NUL byte.</p></div>
2287 </div>
2288 </div>
2289 <div class="sect1">
2290 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2291 <div class="sectionbody">
2292 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2293 can take <code>-c</code> or <code>--cc</code> option
2294 to generate diff output also for merge commits. The output differs
2295 from the format described above in the following way:</p></div>
2296 <div class="olist arabic"><ol class="arabic">
2297 <li>
2299 there is a colon for each parent
2300 </p>
2301 </li>
2302 <li>
2304 there are more "src" modes and "src" sha1
2305 </p>
2306 </li>
2307 <li>
2309 status is concatenated status characters for each parent
2310 </p>
2311 </li>
2312 <li>
2314 no optional "score" number
2315 </p>
2316 </li>
2317 <li>
2319 tab-separated pathname(s) of the file
2320 </p>
2321 </li>
2322 </ol></div>
2323 <div class="paragraph"><p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even
2324 if the file was renamed on any side of history. With
2325 <code>--combined-all-paths</code>, the name of the path in each parent is shown
2326 followed by the name of the path in the merge commit.</p></div>
2327 <div class="paragraph"><p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p></div>
2328 <div class="listingblock">
2329 <div class="content">
2330 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
2331 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
2332 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</code></pre>
2333 </div></div>
2334 <div class="paragraph"><p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p></div>
2335 <div class="listingblock">
2336 <div class="content">
2337 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
2338 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2339 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</code></pre>
2340 </div></div>
2341 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2342 all parents.</p></div>
2343 </div>
2344 </div>
2345 <div class="sect1">
2346 <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2>
2347 <div class="sectionbody">
2348 <div class="paragraph"><p>Running
2349 <a href="git-diff.html">git-diff(1)</a>,
2350 <a href="git-log.html">git-log(1)</a>,
2351 <a href="git-show.html">git-show(1)</a>,
2352 <a href="git-diff-index.html">git-diff-index(1)</a>,
2353 <a href="git-diff-tree.html">git-diff-tree(1)</a>, or
2354 <a href="git-diff-files.html">git-diff-files(1)</a>
2355 with the <code>-p</code> option produces patch text.
2356 You can customize the creation of patch text via the
2357 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables
2358 (see <a href="git.html">git(1)</a>), and the <code>diff</code> attribute (see <a href="gitattributes.html">gitattributes(5)</a>).</p></div>
2359 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2360 diff format:</p></div>
2361 <div class="olist arabic"><ol class="arabic">
2362 <li>
2364 It is preceded with a "git diff" header that looks like this:
2365 </p>
2366 <div class="literalblock">
2367 <div class="content">
2368 <pre><code>diff --git a/file1 b/file2</code></pre>
2369 </div></div>
2370 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2371 involved. Especially, even for a creation or a deletion,
2372 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2373 <div class="paragraph"><p>When rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2374 name of the source file of the rename/copy and the name of
2375 the file that rename/copy produces, respectively.</p></div>
2376 </li>
2377 <li>
2379 It is followed by one or more extended header lines:
2380 </p>
2381 <div class="literalblock">
2382 <div class="content">
2383 <pre><code>old mode &lt;mode&gt;
2384 new mode &lt;mode&gt;
2385 deleted file mode &lt;mode&gt;
2386 new file mode &lt;mode&gt;
2387 copy from &lt;path&gt;
2388 copy to &lt;path&gt;
2389 rename from &lt;path&gt;
2390 rename to &lt;path&gt;
2391 similarity index &lt;number&gt;
2392 dissimilarity index &lt;number&gt;
2393 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</code></pre>
2394 </div></div>
2395 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2396 and file permission bits.</p></div>
2397 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2398 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2399 the dissimilarity index is the percentage of changed lines. It
2400 is a rounded down integer, followed by a percent sign. The
2401 similarity index value of 100% is thus reserved for two equal
2402 files, while 100% dissimilarity means that no line from the old
2403 file made it into the new one.</p></div>
2404 <div class="paragraph"><p>The index line includes the blob object names before and after the change.
2405 The &lt;mode&gt; is included if the file mode does not change; otherwise,
2406 separate lines indicate the old and the new mode.</p></div>
2407 </li>
2408 <li>
2410 Pathnames with "unusual" characters are quoted as explained for
2411 the configuration variable <code>core.quotePath</code> (see
2412 <a href="git-config.html">git-config(1)</a>).
2413 </p>
2414 </li>
2415 <li>
2417 All the <code>file1</code> files in the output refer to files before the
2418 commit, and all the <code>file2</code> files refer to files after the commit.
2419 It is incorrect to apply each change to each file sequentially. For
2420 example, this patch will swap a and b:
2421 </p>
2422 <div class="literalblock">
2423 <div class="content">
2424 <pre><code>diff --git a/a b/b
2425 rename from a
2426 rename to b
2427 diff --git a/b b/a
2428 rename from b
2429 rename to a</code></pre>
2430 </div></div>
2431 </li>
2432 <li>
2434 Hunk headers mention the name of the function to which the hunk
2435 applies. See "Defining a custom hunk-header" in
2436 <a href="gitattributes.html">gitattributes(5)</a> for details of how to tailor to this to
2437 specific languages.
2438 </p>
2439 </li>
2440 </ol></div>
2441 </div>
2442 </div>
2443 <div class="sect1">
2444 <h2 id="_combined_diff_format">Combined diff format</h2>
2445 <div class="sectionbody">
2446 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2447 produce a <em>combined diff</em> when showing a merge. This is the default
2448 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2449 <a href="git-show.html">git-show(1)</a>. Note also that you can give suitable
2450 <code>--diff-merges</code> option to any of these commands to force generation of
2451 diffs in specific format.</p></div>
2452 <div class="paragraph"><p>A "combined diff" format looks like this:</p></div>
2453 <div class="listingblock">
2454 <div class="content">
2455 <pre><code>diff --combined describe.c
2456 index fabadb8,cc95eb0..4866510
2457 --- a/describe.c
2458 +++ b/describe.c
2459 @@@ -98,20 -98,12 +98,20 @@@
2460 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2463 - static void describe(char *arg)
2464 -static void describe(struct commit *cmit, int last_one)
2465 ++static void describe(char *arg, int last_one)
2467 + unsigned char sha1[20];
2468 + struct commit *cmit;
2469 struct commit_list *list;
2470 static int initialized = 0;
2471 struct commit_name *n;
2473 + if (get_sha1(arg, sha1) &lt; 0)
2474 + usage(describe_usage);
2475 + cmit = lookup_commit_reference(sha1);
2476 + if (!cmit)
2477 + usage(describe_usage);
2479 if (!initialized) {
2480 initialized = 1;
2481 for_each_ref(get_name);</code></pre>
2482 </div></div>
2483 <div class="olist arabic"><ol class="arabic">
2484 <li>
2486 It is preceded with a "git diff" header, that looks like
2487 this (when the <code>-c</code> option is used):
2488 </p>
2489 <div class="literalblock">
2490 <div class="content">
2491 <pre><code>diff --combined file</code></pre>
2492 </div></div>
2493 <div class="paragraph"><p>or like this (when the <code>--cc</code> option is used):</p></div>
2494 <div class="literalblock">
2495 <div class="content">
2496 <pre><code>diff --cc file</code></pre>
2497 </div></div>
2498 </li>
2499 <li>
2501 It is followed by one or more extended header lines
2502 (this example shows a merge with two parents):
2503 </p>
2504 <div class="literalblock">
2505 <div class="content">
2506 <pre><code>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
2507 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
2508 new file mode &lt;mode&gt;
2509 deleted file mode &lt;mode&gt;,&lt;mode&gt;</code></pre>
2510 </div></div>
2511 <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
2512 the &lt;mode&gt; is different from the rest. Extended headers with
2513 information about detected contents movement (renames and
2514 copying detection) are designed to work with diff of two
2515 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
2516 </li>
2517 <li>
2519 It is followed by two-line from-file/to-file header
2520 </p>
2521 <div class="literalblock">
2522 <div class="content">
2523 <pre><code>--- a/file
2524 +++ b/file</code></pre>
2525 </div></div>
2526 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
2527 format, <code>/dev/null</code> is used to signal created or deleted
2528 files.</p></div>
2529 <div class="paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2530 two-line from-file/to-file you get a N+1 line from-file/to-file header,
2531 where N is the number of parents in the merge commit</p></div>
2532 <div class="literalblock">
2533 <div class="content">
2534 <pre><code>--- a/file
2535 --- a/file
2536 --- a/file
2537 +++ b/file</code></pre>
2538 </div></div>
2539 <div class="paragraph"><p>This extended format can be useful if rename or copy detection is
2540 active, to allow you to see the original name of the file in different
2541 parents.</p></div>
2542 </li>
2543 <li>
2545 Chunk header format is modified to prevent people from
2546 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2547 was created for review of merge commit changes, and was not
2548 meant to be applied. The change is similar to the change in the
2549 extended <em>index</em> header:
2550 </p>
2551 <div class="literalblock">
2552 <div class="content">
2553 <pre><code>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</code></pre>
2554 </div></div>
2555 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2556 header for combined diff format.</p></div>
2557 </li>
2558 </ol></div>
2559 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2560 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
2561 added to B), or <code>" "</code> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
2562 compares two or more files file1, file2,&#8230; with one file X, and
2563 shows how X differs from each of fileN. One column for each of
2564 fileN is prepended to the output line to note how X&#8217;s line is
2565 different from it.</p></div>
2566 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2567 fileN but it does not appear in the result. A <code>+</code> character
2568 in the column N means that the line appears in the result,
2569 and fileN does not have that line (in other words, the line was
2570 added, from the point of view of that parent).</p></div>
2571 <div class="paragraph"><p>In the above example output, the function signature was changed
2572 from both files (hence two <code>-</code> removals from both file1 and
2573 file2, plus <code>++</code> to mean one line that was added does not appear
2574 in either file1 or file2). Also eight other lines are the same
2575 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2576 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2577 merge commit with the merge result (i.e. file1..fileN are the
2578 parents). When shown by <code>git diff-files -c</code>, it compares the
2579 two unresolved merge parents with the working tree file
2580 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2581 "their version").</p></div>
2582 </div>
2583 </div>
2584 <div class="sect1">
2585 <h2 id="_other_diff_formats">other diff formats</h2>
2586 <div class="sectionbody">
2587 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2588 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2589 output. These options can be combined with other options, such as
2590 <code>-p</code>, and are meant for human consumption.</p></div>
2591 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2592 formats the pathnames compactly by combining common prefix and suffix of
2593 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2594 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2595 <div class="listingblock">
2596 <div class="content">
2597 <pre><code>arch/{i386 =&gt; x86}/Makefile | 4 +--</code></pre>
2598 </div></div>
2599 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2600 for easier machine consumption. An entry in <code>--numstat</code> output looks
2601 like this:</p></div>
2602 <div class="listingblock">
2603 <div class="content">
2604 <pre><code>1 2 README
2605 3 1 arch/{i386 =&gt; x86}/Makefile</code></pre>
2606 </div></div>
2607 <div class="paragraph"><p>That is, from left to right:</p></div>
2608 <div class="olist arabic"><ol class="arabic">
2609 <li>
2611 the number of added lines;
2612 </p>
2613 </li>
2614 <li>
2616 a tab;
2617 </p>
2618 </li>
2619 <li>
2621 the number of deleted lines;
2622 </p>
2623 </li>
2624 <li>
2626 a tab;
2627 </p>
2628 </li>
2629 <li>
2631 pathname (possibly with rename/copy information);
2632 </p>
2633 </li>
2634 <li>
2636 a newline.
2637 </p>
2638 </li>
2639 </ol></div>
2640 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2641 <div class="listingblock">
2642 <div class="content">
2643 <pre><code>1 2 README NUL
2644 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2645 </div></div>
2646 <div class="paragraph"><p>That is:</p></div>
2647 <div class="olist arabic"><ol class="arabic">
2648 <li>
2650 the number of added lines;
2651 </p>
2652 </li>
2653 <li>
2655 a tab;
2656 </p>
2657 </li>
2658 <li>
2660 the number of deleted lines;
2661 </p>
2662 </li>
2663 <li>
2665 a tab;
2666 </p>
2667 </li>
2668 <li>
2670 a NUL (only exists if renamed/copied);
2671 </p>
2672 </li>
2673 <li>
2675 pathname in preimage;
2676 </p>
2677 </li>
2678 <li>
2680 a NUL (only exists if renamed/copied);
2681 </p>
2682 </li>
2683 <li>
2685 pathname in postimage (only exists if renamed/copied);
2686 </p>
2687 </li>
2688 <li>
2690 a NUL.
2691 </p>
2692 </li>
2693 </ol></div>
2694 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2695 scripts that read the output to tell if the current record being read is
2696 a single-path record or a rename/copy record without reading ahead.
2697 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2698 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2699 </div>
2700 </div>
2701 <div class="sect1">
2702 <h2 id="_operating_modes">OPERATING MODES</h2>
2703 <div class="sectionbody">
2704 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
2705 (using the <code>--cached</code> flag) or ask the diff logic to show any files
2706 that don&#8217;t match the stat state as being "tentatively changed". Both
2707 of these operations are very useful indeed.</p></div>
2708 </div>
2709 </div>
2710 <div class="sect1">
2711 <h2 id="_cached_mode">CACHED MODE</h2>
2712 <div class="sectionbody">
2713 <div class="paragraph"><p>If <code>--cached</code> is specified, it allows you to ask:</p></div>
2714 <div class="literalblock">
2715 <div class="content">
2716 <pre><code>show me the differences between HEAD and the current index
2717 contents (the ones I'd write using 'git write-tree')</code></pre>
2718 </div></div>
2719 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
2720 some files in the index and are ready to commit. You want to see exactly
2721 <strong>what</strong> you are going to commit, without having to write a new tree
2722 object and compare it that way, and to do that, you just do</p></div>
2723 <div class="literalblock">
2724 <div class="content">
2725 <pre><code>git diff-index --cached HEAD</code></pre>
2726 </div></div>
2727 <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
2728 done an <code>update-index</code> to make that effective in the index file.
2729 <code>git diff-files</code> wouldn&#8217;t show anything at all, since the index file
2730 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
2731 <div class="literalblock">
2732 <div class="content">
2733 <pre><code>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
2734 :100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D commit.c
2735 :000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git-commit.c</code></pre>
2736 </div></div>
2737 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
2738 <div class="paragraph"><p>In fact, <code>git diff-index --cached</code> <strong>should</strong> always be entirely equivalent to
2739 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
2740 nicer for the case where you just want to check where you are.</p></div>
2741 <div class="paragraph"><p>So doing a <code>git diff-index --cached</code> is basically very useful when you are
2742 asking yourself "what have I already marked for being committed, and
2743 what&#8217;s the difference to a previous tree".</p></div>
2744 </div>
2745 </div>
2746 <div class="sect1">
2747 <h2 id="_non_cached_mode">NON-CACHED MODE</h2>
2748 <div class="sectionbody">
2749 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
2750 the more useful of the two in that what it does can&#8217;t be emulated with
2751 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
2752 The non-cached version asks the question:</p></div>
2753 <div class="literalblock">
2754 <div class="content">
2755 <pre><code>show me the differences between HEAD and the currently checked out
2756 tree - index contents _and_ files that aren't up to date</code></pre>
2757 </div></div>
2758 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
2759 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
2760 output to a tee, but with a twist.</p></div>
2761 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
2762 a backing store thing for it, and we use the magic "all-zero" sha1 to
2763 show that. So let&#8217;s say that you have edited <code>kernel/sched.c</code>, but
2764 have not actually done a <em>git update-index</em> on it yet - there is no
2765 "object" associated with the new state, and you get:</p></div>
2766 <div class="literalblock">
2767 <div class="content">
2768 <pre><code>torvalds@ppc970:~/v2.6/linux&gt; git diff-index --abbrev HEAD
2769 :100644 100644 7476bb5ba 000000000 M kernel/sched.c</code></pre>
2770 </div></div>
2771 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <code>kernel/sched.c</code> is
2772 not up to date and may contain new stuff. The all-zero sha1 means that to
2773 get the real diff, you need to look at the object in the working directory
2774 directly rather than do an object-to-object diff.</p></div>
2775 <div class="admonitionblock">
2776 <table><tr>
2777 <td class="icon">
2778 <div class="title">Note</div>
2779 </td>
2780 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
2781 actually look at the contents of the file at all. So maybe
2782 <code>kernel/sched.c</code> hasn&#8217;t actually changed, and it&#8217;s just that you
2783 touched it. In either case, it&#8217;s a note that you need to
2784 <em>git update-index</em> it to make the index be in sync.</td>
2785 </tr></table>
2786 </div>
2787 <div class="admonitionblock">
2788 <table><tr>
2789 <td class="icon">
2790 <div class="title">Note</div>
2791 </td>
2792 <td class="content">You can have a mixture of files show up as "has been updated"
2793 and "is still dirty in the working directory" together. You can always
2794 tell which file is in which state, since the "has been updated" ones
2795 show a valid sha1, and the "not in sync with the index" ones will
2796 always have the special all-zero sha1.</td>
2797 </tr></table>
2798 </div>
2799 </div>
2800 </div>
2801 <div class="sect1">
2802 <h2 id="_git">GIT</h2>
2803 <div class="sectionbody">
2804 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2805 </div>
2806 </div>
2807 </div>
2808 <div id="footnotes"><hr /></div>
2809 <div id="footer">
2810 <div id="footer-text">
2811 Last updated
2812 2022-07-11 16:06:18 PDT
2813 </div>
2814 </div>
2815 </body>
2816 </html>