Autogenerated HTML docs for v2.42.0-241-g6bdb5
[git-htmldocs.git] / git-diff.html
blob9b747eb58999c76fbcc204866fcd9ccf4ec95730
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(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(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-diff -
743 Show changes between commits, commit and working tree, etc
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</em> [&lt;options&gt;] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
753 <em>git diff</em> [&lt;options&gt;] --cached [--merge-base] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
754 <em>git diff</em> [&lt;options&gt;] [--merge-base] &lt;commit&gt; [&lt;commit&gt;&#8230;] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
755 <em>git diff</em> [&lt;options&gt;] &lt;commit&gt;&#8230;&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
756 <em>git diff</em> [&lt;options&gt;] &lt;blob&gt; &lt;blob&gt;
757 <em>git diff</em> [&lt;options&gt;] --no-index [--] &lt;path&gt; &lt;path&gt;</pre>
758 <div class="attribution">
759 </div></div>
760 </div>
761 </div>
762 <div class="sect1">
763 <h2 id="_description">DESCRIPTION</h2>
764 <div class="sectionbody">
765 <div class="paragraph"><p>Show changes between the working tree and the index or a tree, changes
766 between the index and a tree, changes between two trees, changes resulting
767 from a merge, changes between two blob objects, or changes between two
768 files on disk.</p></div>
769 <div class="dlist"><dl>
770 <dt class="hdlist1">
771 <em>git diff</em> [&lt;options&gt;] [--] [&lt;path&gt;&#8230;]
772 </dt>
773 <dd>
775 This form is to view the changes you made relative to
776 the index (staging area for the next commit). In other
777 words, the differences are what you <em>could</em> tell Git to
778 further add to the index but you still haven&#8217;t. You can
779 stage these changes by using <a href="git-add.html">git-add(1)</a>.
780 </p>
781 </dd>
782 <dt class="hdlist1">
783 <em>git diff</em> [&lt;options&gt;] --no-index [--] &lt;path&gt; &lt;path&gt;
784 </dt>
785 <dd>
787 This form is to compare the given two paths on the
788 filesystem. You can omit the <code>--no-index</code> option when
789 running the command in a working tree controlled by Git and
790 at least one of the paths points outside the working tree,
791 or when running the command outside a working tree
792 controlled by Git. This form implies <code>--exit-code</code>.
793 </p>
794 </dd>
795 <dt class="hdlist1">
796 <em>git diff</em> [&lt;options&gt;] --cached [--merge-base] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
797 </dt>
798 <dd>
800 This form is to view the changes you staged for the next
801 commit relative to the named &lt;commit&gt;. Typically you
802 would want comparison with the latest commit, so if you
803 do not give &lt;commit&gt;, it defaults to HEAD.
804 If HEAD does not exist (e.g. unborn branches) and
805 &lt;commit&gt; is not given, it shows all staged changes.
806 --staged is a synonym of --cached.
807 </p>
808 <div class="paragraph"><p>If --merge-base is given, instead of using &lt;commit&gt;, use the merge base
809 of &lt;commit&gt; and HEAD. <code>git diff --cached --merge-base A</code> is equivalent to
810 <code>git diff --cached $(git merge-base A HEAD)</code>.</p></div>
811 </dd>
812 <dt class="hdlist1">
813 <em>git diff</em> [&lt;options&gt;] [--merge-base] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
814 </dt>
815 <dd>
817 This form is to view the changes you have in your
818 working tree relative to the named &lt;commit&gt;. You can
819 use HEAD to compare it with the latest commit, or a
820 branch name to compare with the tip of a different
821 branch.
822 </p>
823 <div class="paragraph"><p>If --merge-base is given, instead of using &lt;commit&gt;, use the merge base
824 of &lt;commit&gt; and HEAD. <code>git diff --merge-base A</code> is equivalent to
825 <code>git diff $(git merge-base A HEAD)</code>.</p></div>
826 </dd>
827 <dt class="hdlist1">
828 <em>git diff</em> [&lt;options&gt;] [--merge-base] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
829 </dt>
830 <dd>
832 This is to view the changes between two arbitrary
833 &lt;commit&gt;.
834 </p>
835 <div class="paragraph"><p>If --merge-base is given, use the merge base of the two commits for the
836 "before" side. <code>git diff --merge-base A B</code> is equivalent to
837 <code>git diff $(git merge-base A B) B</code>.</p></div>
838 </dd>
839 <dt class="hdlist1">
840 <em>git diff</em> [&lt;options&gt;] &lt;commit&gt; &lt;commit&gt;&#8230; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
841 </dt>
842 <dd>
844 This form is to view the results of a merge commit. The first
845 listed &lt;commit&gt; must be the merge itself; the remaining two or
846 more commits should be its parents. Convenient ways to produce
847 the desired set of revisions are to use the suffixes <code>^@</code> and
848 <code>^!</code>. If A is a merge commit, then <code>git diff A A^@</code>,
849 <code>git diff A^!</code> and <code>git show A</code> all give the same combined diff.
850 </p>
851 </dd>
852 <dt class="hdlist1">
853 <em>git diff</em> [&lt;options&gt;] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
854 </dt>
855 <dd>
857 This is synonymous to the earlier form (without the <code>..</code>) for
858 viewing the changes between two arbitrary &lt;commit&gt;. If &lt;commit&gt; on
859 one side is omitted, it will have the same effect as
860 using HEAD instead.
861 </p>
862 </dd>
863 <dt class="hdlist1">
864 <em>git diff</em> [&lt;options&gt;] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
865 </dt>
866 <dd>
868 This form is to view the changes on the branch containing
869 and up to the second &lt;commit&gt;, starting at a common ancestor
870 of both &lt;commit&gt;. <code>git diff A...B</code> is equivalent to
871 <code>git diff $(git merge-base A B) B</code>. You can omit any one
872 of &lt;commit&gt;, which has the same effect as using HEAD instead.
873 </p>
874 </dd>
875 </dl></div>
876 <div class="paragraph"><p>Just in case you are doing something exotic, it should be
877 noted that all of the &lt;commit&gt; in the above description, except
878 in the <code>--merge-base</code> case and in the last two forms that use <code>..</code>
879 notations, can be any &lt;tree&gt;. A tree of interest is the one pointed to
880 by the special ref <code>AUTO_MERGE</code>, which is written by the <em>ort</em> merge
881 strategy upon hitting merge conflicts (see <a href="git-merge.html">git-merge(1)</a>).
882 Comparing the working tree with <code>AUTO_MERGE</code> shows changes you&#8217;ve made
883 so far to resolve textual conflicts (see the examples below).</p></div>
884 <div class="paragraph"><p>For a more complete list of ways to spell &lt;commit&gt;, see
885 "SPECIFYING REVISIONS" section in <a href="gitrevisions.html">gitrevisions(7)</a>.
886 However, "diff" is about comparing two <em>endpoints</em>, not ranges,
887 and the range notations (<code>&lt;commit&gt;..&lt;commit&gt;</code> and
888 <code>&lt;commit&gt;...&lt;commit&gt;</code>) do not mean a range as defined in the
889 "SPECIFYING RANGES" section in <a href="gitrevisions.html">gitrevisions(7)</a>.</p></div>
890 <div class="dlist"><dl>
891 <dt class="hdlist1">
892 <em>git diff</em> [&lt;options&gt;] &lt;blob&gt; &lt;blob&gt;
893 </dt>
894 <dd>
896 This form is to view the differences between the raw
897 contents of two blob objects.
898 </p>
899 </dd>
900 </dl></div>
901 </div>
902 </div>
903 <div class="sect1">
904 <h2 id="_options">OPTIONS</h2>
905 <div class="sectionbody">
906 <div class="dlist"><dl>
907 <dt class="hdlist1">
909 </dt>
910 <dt class="hdlist1">
912 </dt>
913 <dt class="hdlist1">
914 --patch
915 </dt>
916 <dd>
918 Generate patch (see <a href="#generate_patch_text_with_p">[generate_patch_text_with_p]</a>).
919 This is the default.
920 </p>
921 </dd>
922 <dt class="hdlist1">
924 </dt>
925 <dt class="hdlist1">
926 --no-patch
927 </dt>
928 <dd>
930 Suppress all output from the diff machinery. Useful for
931 commands like <code>git show</code> that show the patch by default to
932 squelch their output, or to cancel the effect of options like
933 <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.
934 </p>
935 </dd>
936 <dt class="hdlist1">
937 -U&lt;n&gt;
938 </dt>
939 <dt class="hdlist1">
940 --unified=&lt;n&gt;
941 </dt>
942 <dd>
944 Generate diffs with &lt;n&gt; lines of context instead of
945 the usual three.
946 Implies <code>--patch</code>.
947 </p>
948 </dd>
949 <dt class="hdlist1">
950 --output=&lt;file&gt;
951 </dt>
952 <dd>
954 Output to a specific file instead of stdout.
955 </p>
956 </dd>
957 <dt class="hdlist1">
958 --output-indicator-new=&lt;char&gt;
959 </dt>
960 <dt class="hdlist1">
961 --output-indicator-old=&lt;char&gt;
962 </dt>
963 <dt class="hdlist1">
964 --output-indicator-context=&lt;char&gt;
965 </dt>
966 <dd>
968 Specify the character used to indicate new, old or context
969 lines in the generated patch. Normally they are <em>+</em>, <em>-</em> and
970 ' ' respectively.
971 </p>
972 </dd>
973 <dt class="hdlist1">
974 --raw
975 </dt>
976 <dd>
978 Generate the diff in raw format.
979 </p>
980 </dd>
981 <dt class="hdlist1">
982 --patch-with-raw
983 </dt>
984 <dd>
986 Synonym for <code>-p --raw</code>.
987 </p>
988 </dd>
989 <dt class="hdlist1">
990 --indent-heuristic
991 </dt>
992 <dd>
994 Enable the heuristic that shifts diff hunk boundaries to make patches
995 easier to read. This is the default.
996 </p>
997 </dd>
998 <dt class="hdlist1">
999 --no-indent-heuristic
1000 </dt>
1001 <dd>
1003 Disable the indent heuristic.
1004 </p>
1005 </dd>
1006 <dt class="hdlist1">
1007 --minimal
1008 </dt>
1009 <dd>
1011 Spend extra time to make sure the smallest possible
1012 diff is produced.
1013 </p>
1014 </dd>
1015 <dt class="hdlist1">
1016 --patience
1017 </dt>
1018 <dd>
1020 Generate a diff using the "patience diff" algorithm.
1021 </p>
1022 </dd>
1023 <dt class="hdlist1">
1024 --histogram
1025 </dt>
1026 <dd>
1028 Generate a diff using the "histogram diff" algorithm.
1029 </p>
1030 </dd>
1031 <dt class="hdlist1">
1032 --anchored=&lt;text&gt;
1033 </dt>
1034 <dd>
1036 Generate a diff using the "anchored diff" algorithm.
1037 </p>
1038 <div class="paragraph"><p>This option may be specified more than once.</p></div>
1039 <div class="paragraph"><p>If a line exists in both the source and destination, exists only once,
1040 and starts with this text, this algorithm attempts to prevent it from
1041 appearing as a deletion or addition in the output. It uses the "patience
1042 diff" algorithm internally.</p></div>
1043 </dd>
1044 <dt class="hdlist1">
1045 --diff-algorithm={patience|minimal|histogram|myers}
1046 </dt>
1047 <dd>
1049 Choose a diff algorithm. The variants are as follows:
1050 </p>
1051 <div class="openblock">
1052 <div class="content">
1053 <div class="dlist"><dl>
1054 <dt class="hdlist1">
1055 <code>default</code>, <code>myers</code>
1056 </dt>
1057 <dd>
1059 The basic greedy diff algorithm. Currently, this is the default.
1060 </p>
1061 </dd>
1062 <dt class="hdlist1">
1063 <code>minimal</code>
1064 </dt>
1065 <dd>
1067 Spend extra time to make sure the smallest possible diff is
1068 produced.
1069 </p>
1070 </dd>
1071 <dt class="hdlist1">
1072 <code>patience</code>
1073 </dt>
1074 <dd>
1076 Use "patience diff" algorithm when generating patches.
1077 </p>
1078 </dd>
1079 <dt class="hdlist1">
1080 <code>histogram</code>
1081 </dt>
1082 <dd>
1084 This algorithm extends the patience algorithm to "support
1085 low-occurrence common elements".
1086 </p>
1087 </dd>
1088 </dl></div>
1089 </div></div>
1090 <div class="paragraph"><p>For instance, if you configured the <code>diff.algorithm</code> variable to a
1091 non-default value and want to use the default one, then you
1092 have to use <code>--diff-algorithm=default</code> option.</p></div>
1093 </dd>
1094 <dt class="hdlist1">
1095 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
1096 </dt>
1097 <dd>
1099 Generate a diffstat. By default, as much space as necessary
1100 will be used for the filename part, and the rest for the graph
1101 part. Maximum width defaults to terminal width, or 80 columns
1102 if not connected to a terminal, and can be overridden by
1103 <code>&lt;width&gt;</code>. The width of the filename part can be limited by
1104 giving another width <code>&lt;name-width&gt;</code> after a comma. The width
1105 of the graph part can be limited by using
1106 <code>--stat-graph-width=&lt;width&gt;</code> (affects all commands generating
1107 a stat graph) or by setting <code>diff.statGraphWidth=&lt;width&gt;</code>
1108 (does not affect <code>git format-patch</code>).
1109 By giving a third parameter <code>&lt;count&gt;</code>, you can limit the
1110 output to the first <code>&lt;count&gt;</code> lines, followed by <code>...</code> if
1111 there are more.
1112 </p>
1113 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=&lt;width&gt;</code>,
1114 <code>--stat-name-width=&lt;name-width&gt;</code> and <code>--stat-count=&lt;count&gt;</code>.</p></div>
1115 </dd>
1116 <dt class="hdlist1">
1117 --compact-summary
1118 </dt>
1119 <dd>
1121 Output a condensed summary of extended header information such
1122 as file creations or deletions ("new" or "gone", optionally "+l"
1123 if it&#8217;s a symlink) and mode changes ("+x" or "-x" for adding
1124 or removing executable bit respectively) in diffstat. The
1125 information is put between the filename part and the graph
1126 part. Implies <code>--stat</code>.
1127 </p>
1128 </dd>
1129 <dt class="hdlist1">
1130 --numstat
1131 </dt>
1132 <dd>
1134 Similar to <code>--stat</code>, but shows number of added and
1135 deleted lines in decimal notation and pathname without
1136 abbreviation, to make it more machine friendly. For
1137 binary files, outputs two <code>-</code> instead of saying
1138 <code>0 0</code>.
1139 </p>
1140 </dd>
1141 <dt class="hdlist1">
1142 --shortstat
1143 </dt>
1144 <dd>
1146 Output only the last line of the <code>--stat</code> format containing total
1147 number of modified files, as well as number of added and deleted
1148 lines.
1149 </p>
1150 </dd>
1151 <dt class="hdlist1">
1152 -X[&lt;param1,param2,&#8230;&gt;]
1153 </dt>
1154 <dt class="hdlist1">
1155 --dirstat[=&lt;param1,param2,&#8230;&gt;]
1156 </dt>
1157 <dd>
1159 Output the distribution of relative amount of changes for each
1160 sub-directory. The behavior of <code>--dirstat</code> can be customized by
1161 passing it a comma separated list of parameters.
1162 The defaults are controlled by the <code>diff.dirstat</code> configuration
1163 variable (see <a href="git-config.html">git-config(1)</a>).
1164 The following parameters are available:
1165 </p>
1166 <div class="openblock">
1167 <div class="content">
1168 <div class="dlist"><dl>
1169 <dt class="hdlist1">
1170 <code>changes</code>
1171 </dt>
1172 <dd>
1174 Compute the dirstat numbers by counting the lines that have been
1175 removed from the source, or added to the destination. This ignores
1176 the amount of pure code movements within a file. In other words,
1177 rearranging lines in a file is not counted as much as other changes.
1178 This is the default behavior when no parameter is given.
1179 </p>
1180 </dd>
1181 <dt class="hdlist1">
1182 <code>lines</code>
1183 </dt>
1184 <dd>
1186 Compute the dirstat numbers by doing the regular line-based diff
1187 analysis, and summing the removed/added line counts. (For binary
1188 files, count 64-byte chunks instead, since binary files have no
1189 natural concept of lines). This is a more expensive <code>--dirstat</code>
1190 behavior than the <code>changes</code> behavior, but it does count rearranged
1191 lines within a file as much as other changes. The resulting output
1192 is consistent with what you get from the other <code>--*stat</code> options.
1193 </p>
1194 </dd>
1195 <dt class="hdlist1">
1196 <code>files</code>
1197 </dt>
1198 <dd>
1200 Compute the dirstat numbers by counting the number of files changed.
1201 Each changed file counts equally in the dirstat analysis. This is
1202 the computationally cheapest <code>--dirstat</code> behavior, since it does
1203 not have to look at the file contents at all.
1204 </p>
1205 </dd>
1206 <dt class="hdlist1">
1207 <code>cumulative</code>
1208 </dt>
1209 <dd>
1211 Count changes in a child directory for the parent directory as well.
1212 Note that when using <code>cumulative</code>, the sum of the percentages
1213 reported may exceed 100%. The default (non-cumulative) behavior can
1214 be specified with the <code>noncumulative</code> parameter.
1215 </p>
1216 </dd>
1217 <dt class="hdlist1">
1218 &lt;limit&gt;
1219 </dt>
1220 <dd>
1222 An integer parameter specifies a cut-off percent (3% by default).
1223 Directories contributing less than this percentage of the changes
1224 are not shown in the output.
1225 </p>
1226 </dd>
1227 </dl></div>
1228 </div></div>
1229 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1230 directories with less than 10% of the total amount of changed files,
1231 and accumulating child directory counts in the parent directories:
1232 <code>--dirstat=files,10,cumulative</code>.</p></div>
1233 </dd>
1234 <dt class="hdlist1">
1235 --cumulative
1236 </dt>
1237 <dd>
1239 Synonym for --dirstat=cumulative
1240 </p>
1241 </dd>
1242 <dt class="hdlist1">
1243 --dirstat-by-file[=&lt;param1,param2&gt;&#8230;]
1244 </dt>
1245 <dd>
1247 Synonym for --dirstat=files,param1,param2&#8230;
1248 </p>
1249 </dd>
1250 <dt class="hdlist1">
1251 --summary
1252 </dt>
1253 <dd>
1255 Output a condensed summary of extended header information
1256 such as creations, renames and mode changes.
1257 </p>
1258 </dd>
1259 <dt class="hdlist1">
1260 --patch-with-stat
1261 </dt>
1262 <dd>
1264 Synonym for <code>-p --stat</code>.
1265 </p>
1266 </dd>
1267 <dt class="hdlist1">
1269 </dt>
1270 <dd>
1272 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1273 given, do not munge pathnames and use NULs as output field terminators.
1274 </p>
1275 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1276 explained for the configuration variable <code>core.quotePath</code> (see
1277 <a href="git-config.html">git-config(1)</a>).</p></div>
1278 </dd>
1279 <dt class="hdlist1">
1280 --name-only
1281 </dt>
1282 <dd>
1284 Show only names of changed files. The file names are often encoded in UTF-8.
1285 For more information see the discussion about encoding in the <a href="git-log.html">git-log(1)</a>
1286 manual page.
1287 </p>
1288 </dd>
1289 <dt class="hdlist1">
1290 --name-status
1291 </dt>
1292 <dd>
1294 Show only names and status of changed files. See the description
1295 of the <code>--diff-filter</code> option on what the status letters mean.
1296 Just like <code>--name-only</code> the file names are often encoded in UTF-8.
1297 </p>
1298 </dd>
1299 <dt class="hdlist1">
1300 --submodule[=&lt;format&gt;]
1301 </dt>
1302 <dd>
1304 Specify how differences in submodules are shown. When specifying
1305 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1306 shows the names of the commits at the beginning and end of the range.
1307 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1308 format is used. This format lists the commits in the range like
1309 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1310 is specified, the <em>diff</em> format is used. This format shows an
1311 inline diff of the changes in the submodule contents between the
1312 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1313 if the config option is unset.
1314 </p>
1315 </dd>
1316 <dt class="hdlist1">
1317 --color[=&lt;when&gt;]
1318 </dt>
1319 <dd>
1321 Show colored diff.
1322 <code>--color</code> (i.e. without <em>=&lt;when&gt;</em>) is the same as <code>--color=always</code>.
1323 <em>&lt;when&gt;</em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1324 It can be changed by the <code>color.ui</code> and <code>color.diff</code>
1325 configuration settings.
1326 </p>
1327 </dd>
1328 <dt class="hdlist1">
1329 --no-color
1330 </dt>
1331 <dd>
1333 Turn off colored diff.
1334 This can be used to override configuration settings.
1335 It is the same as <code>--color=never</code>.
1336 </p>
1337 </dd>
1338 <dt class="hdlist1">
1339 --color-moved[=&lt;mode&gt;]
1340 </dt>
1341 <dd>
1343 Moved lines of code are colored differently.
1344 It can be changed by the <code>diff.colorMoved</code> configuration setting.
1345 The &lt;mode&gt; defaults to <em>no</em> if the option is not given
1346 and to <em>zebra</em> if the option with no mode is given.
1347 The mode must be one of:
1348 </p>
1349 <div class="openblock">
1350 <div class="content">
1351 <div class="dlist"><dl>
1352 <dt class="hdlist1">
1354 </dt>
1355 <dd>
1357 Moved lines are not highlighted.
1358 </p>
1359 </dd>
1360 <dt class="hdlist1">
1361 default
1362 </dt>
1363 <dd>
1365 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1366 in the future.
1367 </p>
1368 </dd>
1369 <dt class="hdlist1">
1370 plain
1371 </dt>
1372 <dd>
1374 Any line that is added in one location and was removed
1375 in another location will be colored with <em>color.diff.newMoved</em>.
1376 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1377 that are added somewhere else in the diff. This mode picks up any
1378 moved line, but it is not very useful in a review to determine
1379 if a block of code was moved without permutation.
1380 </p>
1381 </dd>
1382 <dt class="hdlist1">
1383 blocks
1384 </dt>
1385 <dd>
1387 Blocks of moved text of at least 20 alphanumeric characters
1388 are detected greedily. The detected blocks are
1389 painted using either the <em>color.diff.{old,new}Moved</em> color.
1390 Adjacent blocks cannot be told apart.
1391 </p>
1392 </dd>
1393 <dt class="hdlist1">
1394 zebra
1395 </dt>
1396 <dd>
1398 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1399 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1400 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1401 the two colors indicates that a new block was detected.
1402 </p>
1403 </dd>
1404 <dt class="hdlist1">
1405 dimmed-zebra
1406 </dt>
1407 <dd>
1409 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1410 of moved code is performed. The bordering lines of two adjacent
1411 blocks are considered interesting, the rest is uninteresting.
1412 <code>dimmed_zebra</code> is a deprecated synonym.
1413 </p>
1414 </dd>
1415 </dl></div>
1416 </div></div>
1417 </dd>
1418 <dt class="hdlist1">
1419 --no-color-moved
1420 </dt>
1421 <dd>
1423 Turn off move detection. This can be used to override configuration
1424 settings. It is the same as <code>--color-moved=no</code>.
1425 </p>
1426 </dd>
1427 <dt class="hdlist1">
1428 --color-moved-ws=&lt;modes&gt;
1429 </dt>
1430 <dd>
1432 This configures how whitespace is ignored when performing the
1433 move detection for <code>--color-moved</code>.
1434 It can be set by the <code>diff.colorMovedWS</code> configuration setting.
1435 These modes can be given as a comma separated list:
1436 </p>
1437 <div class="openblock">
1438 <div class="content">
1439 <div class="dlist"><dl>
1440 <dt class="hdlist1">
1442 </dt>
1443 <dd>
1445 Do not ignore whitespace when performing move detection.
1446 </p>
1447 </dd>
1448 <dt class="hdlist1">
1449 ignore-space-at-eol
1450 </dt>
1451 <dd>
1453 Ignore changes in whitespace at EOL.
1454 </p>
1455 </dd>
1456 <dt class="hdlist1">
1457 ignore-space-change
1458 </dt>
1459 <dd>
1461 Ignore changes in amount of whitespace. This ignores whitespace
1462 at line end, and considers all other sequences of one or
1463 more whitespace characters to be equivalent.
1464 </p>
1465 </dd>
1466 <dt class="hdlist1">
1467 ignore-all-space
1468 </dt>
1469 <dd>
1471 Ignore whitespace when comparing lines. This ignores differences
1472 even if one line has whitespace where the other line has none.
1473 </p>
1474 </dd>
1475 <dt class="hdlist1">
1476 allow-indentation-change
1477 </dt>
1478 <dd>
1480 Initially ignore any whitespace in the move detection, then
1481 group the moved code blocks only into a block if the change in
1482 whitespace is the same per line. This is incompatible with the
1483 other modes.
1484 </p>
1485 </dd>
1486 </dl></div>
1487 </div></div>
1488 </dd>
1489 <dt class="hdlist1">
1490 --no-color-moved-ws
1491 </dt>
1492 <dd>
1494 Do not ignore whitespace when performing move detection. This can be
1495 used to override configuration settings. It is the same as
1496 <code>--color-moved-ws=no</code>.
1497 </p>
1498 </dd>
1499 <dt class="hdlist1">
1500 --word-diff[=&lt;mode&gt;]
1501 </dt>
1502 <dd>
1504 Show a word diff, using the &lt;mode&gt; to delimit changed words.
1505 By default, words are delimited by whitespace; see
1506 <code>--word-diff-regex</code> below. The &lt;mode&gt; defaults to <em>plain</em>, and
1507 must be one of:
1508 </p>
1509 <div class="openblock">
1510 <div class="content">
1511 <div class="dlist"><dl>
1512 <dt class="hdlist1">
1513 color
1514 </dt>
1515 <dd>
1517 Highlight changed words using only colors. Implies <code>--color</code>.
1518 </p>
1519 </dd>
1520 <dt class="hdlist1">
1521 plain
1522 </dt>
1523 <dd>
1525 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1526 attempts to escape the delimiters if they appear in the input,
1527 so the output may be ambiguous.
1528 </p>
1529 </dd>
1530 <dt class="hdlist1">
1531 porcelain
1532 </dt>
1533 <dd>
1535 Use a special line-based format intended for script
1536 consumption. Added/removed/unchanged runs are printed in the
1537 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1538 character at the beginning of the line and extending to the
1539 end of the line. Newlines in the input are represented by a
1540 tilde <code>~</code> on a line of its own.
1541 </p>
1542 </dd>
1543 <dt class="hdlist1">
1544 none
1545 </dt>
1546 <dd>
1548 Disable word diff again.
1549 </p>
1550 </dd>
1551 </dl></div>
1552 </div></div>
1553 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1554 highlight the changed parts in all modes if enabled.</p></div>
1555 </dd>
1556 <dt class="hdlist1">
1557 --word-diff-regex=&lt;regex&gt;
1558 </dt>
1559 <dd>
1561 Use &lt;regex&gt; to decide what a word is, instead of considering
1562 runs of non-whitespace to be a word. Also implies
1563 <code>--word-diff</code> unless it was already enabled.
1564 </p>
1565 <div class="paragraph"><p>Every non-overlapping match of the
1566 &lt;regex&gt; is considered a word. Anything between these matches is
1567 considered whitespace and ignored(!) for the purposes of finding
1568 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1569 expression to make sure that it matches all non-whitespace characters.
1570 A match that contains a newline is silently truncated(!) at the
1571 newline.</p></div>
1572 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1573 and, correspondingly, show differences character by character.</p></div>
1574 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1575 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1576 overrides any diff driver or configuration setting. Diff drivers
1577 override configuration settings.</p></div>
1578 </dd>
1579 <dt class="hdlist1">
1580 --color-words[=&lt;regex&gt;]
1581 </dt>
1582 <dd>
1584 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1585 specified) <code>--word-diff-regex=&lt;regex&gt;</code>.
1586 </p>
1587 </dd>
1588 <dt class="hdlist1">
1589 --no-renames
1590 </dt>
1591 <dd>
1593 Turn off rename detection, even when the configuration
1594 file gives the default to do so.
1595 </p>
1596 </dd>
1597 <dt class="hdlist1">
1598 --[no-]rename-empty
1599 </dt>
1600 <dd>
1602 Whether to use empty blobs as rename source.
1603 </p>
1604 </dd>
1605 <dt class="hdlist1">
1606 --check
1607 </dt>
1608 <dd>
1610 Warn if changes introduce conflict markers or whitespace errors.
1611 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1612 configuration. By default, trailing whitespaces (including
1613 lines that consist solely of whitespaces) and a space character
1614 that is immediately followed by a tab character inside the
1615 initial indent of the line are considered whitespace errors.
1616 Exits with non-zero status if problems are found. Not compatible
1617 with --exit-code.
1618 </p>
1619 </dd>
1620 <dt class="hdlist1">
1621 --ws-error-highlight=&lt;kind&gt;
1622 </dt>
1623 <dd>
1625 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1626 lines of the diff. Multiple values are separated by comma,
1627 <code>none</code> resets previous values, <code>default</code> reset the list to
1628 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1629 this option is not given, and the configuration variable
1630 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1631 <code>new</code> lines are highlighted. The whitespace errors are colored
1632 with <code>color.diff.whitespace</code>.
1633 </p>
1634 </dd>
1635 <dt class="hdlist1">
1636 --full-index
1637 </dt>
1638 <dd>
1640 Instead of the first handful of characters, show the full
1641 pre- and post-image blob object names on the "index"
1642 line when generating patch format output.
1643 </p>
1644 </dd>
1645 <dt class="hdlist1">
1646 --binary
1647 </dt>
1648 <dd>
1650 In addition to <code>--full-index</code>, output a binary diff that
1651 can be applied with <code>git-apply</code>.
1652 Implies <code>--patch</code>.
1653 </p>
1654 </dd>
1655 <dt class="hdlist1">
1656 --abbrev[=&lt;n&gt;]
1657 </dt>
1658 <dd>
1660 Instead of showing the full 40-byte hexadecimal object
1661 name in diff-raw format output and diff-tree header
1662 lines, show the shortest prefix that is at least <em>&lt;n&gt;</em>
1663 hexdigits long that uniquely refers the object.
1664 In diff-patch output format, <code>--full-index</code> takes higher
1665 precedence, i.e. if <code>--full-index</code> is specified, full blob
1666 names will be shown regardless of <code>--abbrev</code>.
1667 Non default number of digits can be specified with <code>--abbrev=&lt;n&gt;</code>.
1668 </p>
1669 </dd>
1670 <dt class="hdlist1">
1671 -B[&lt;n&gt;][/&lt;m&gt;]
1672 </dt>
1673 <dt class="hdlist1">
1674 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1675 </dt>
1676 <dd>
1678 Break complete rewrite changes into pairs of delete and
1679 create. This serves two purposes:
1680 </p>
1681 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1682 not as a series of deletion and insertion mixed together with a very
1683 few lines that happen to match textually as the context, but as a
1684 single deletion of everything old followed by a single insertion of
1685 everything new, and the number <code>m</code> controls this aspect of the -B
1686 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1687 original should remain in the result for Git to consider it a total
1688 rewrite (i.e. otherwise the resulting patch will be a series of
1689 deletion and insertion mixed together with context lines).</p></div>
1690 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1691 source of a rename (usually -M only considers a file that disappeared
1692 as the source of a rename), and the number <code>n</code> controls this aspect of
1693 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1694 addition and deletion compared to 20% or more of the file&#8217;s size are
1695 eligible for being picked up as a possible source of a rename to
1696 another file.</p></div>
1697 </dd>
1698 <dt class="hdlist1">
1699 -M[&lt;n&gt;]
1700 </dt>
1701 <dt class="hdlist1">
1702 --find-renames[=&lt;n&gt;]
1703 </dt>
1704 <dd>
1706 Detect renames.
1707 If <code>n</code> is specified, it is a threshold on the similarity
1708 index (i.e. amount of addition/deletions compared to the
1709 file&#8217;s size). For example, <code>-M90%</code> means Git should consider a
1710 delete/add pair to be a rename if more than 90% of the file
1711 hasn&#8217;t changed. Without a <code>%</code> sign, the number is to be read as
1712 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1713 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1714 the same as <code>-M5%</code>. To limit detection to exact renames, use
1715 <code>-M100%</code>. The default similarity index is 50%.
1716 </p>
1717 </dd>
1718 <dt class="hdlist1">
1719 -C[&lt;n&gt;]
1720 </dt>
1721 <dt class="hdlist1">
1722 --find-copies[=&lt;n&gt;]
1723 </dt>
1724 <dd>
1726 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1727 If <code>n</code> is specified, it has the same meaning as for <code>-M&lt;n&gt;</code>.
1728 </p>
1729 </dd>
1730 <dt class="hdlist1">
1731 --find-copies-harder
1732 </dt>
1733 <dd>
1735 For performance reasons, by default, <code>-C</code> option finds copies only
1736 if the original file of the copy was modified in the same
1737 changeset. This flag makes the command
1738 inspect unmodified files as candidates for the source of
1739 copy. This is a very expensive operation for large
1740 projects, so use it with caution. Giving more than one
1741 <code>-C</code> option has the same effect.
1742 </p>
1743 </dd>
1744 <dt class="hdlist1">
1746 </dt>
1747 <dt class="hdlist1">
1748 --irreversible-delete
1749 </dt>
1750 <dd>
1752 Omit the preimage for deletes, i.e. print only the header but not
1753 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1754 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1755 solely for people who want to just concentrate on reviewing the
1756 text after the change. In addition, the output obviously lacks
1757 enough information to apply such a patch in reverse, even manually,
1758 hence the name of the option.
1759 </p>
1760 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1761 of a delete/create pair.</p></div>
1762 </dd>
1763 <dt class="hdlist1">
1764 -l&lt;num&gt;
1765 </dt>
1766 <dd>
1768 The <code>-M</code> and <code>-C</code> options involve some preliminary steps that
1769 can detect subsets of renames/copies cheaply, followed by an
1770 exhaustive fallback portion that compares all remaining
1771 unpaired destinations to all relevant sources. (For renames,
1772 only remaining unpaired sources are relevant; for copies, all
1773 original sources are relevant.) For N sources and
1774 destinations, this exhaustive check is O(N^2). This option
1775 prevents the exhaustive portion of rename/copy detection from
1776 running if the number of source/destination files involved
1777 exceeds the specified number. Defaults to diff.renameLimit.
1778 Note that a value of 0 is treated as unlimited.
1779 </p>
1780 </dd>
1781 <dt class="hdlist1">
1782 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1783 </dt>
1784 <dd>
1786 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1787 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1788 type (i.e. regular file, symlink, submodule, &#8230;) changed (<code>T</code>),
1789 are Unmerged (<code>U</code>), are
1790 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1791 Any combination of the filter characters (including none) can be used.
1792 When <code>*</code> (All-or-none) is added to the combination, all
1793 paths are selected if there is any file that matches
1794 other criteria in the comparison; if there is no file
1795 that matches other criteria, nothing is selected.
1796 </p>
1797 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1798 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1799 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1800 renamed entries cannot appear if detection for those types is disabled.</p></div>
1801 </dd>
1802 <dt class="hdlist1">
1803 -S&lt;string&gt;
1804 </dt>
1805 <dd>
1807 Look for differences that change the number of occurrences of
1808 the specified string (i.e. addition/deletion) in a file.
1809 Intended for the scripter&#8217;s use.
1810 </p>
1811 <div class="paragraph"><p>It is useful when you&#8217;re looking for an exact block of code (like a
1812 struct), and want to know the history of that block since it first
1813 came into being: use the feature iteratively to feed the interesting
1814 block in the preimage back into <code>-S</code>, and keep going until you get the
1815 very first version of the block.</p></div>
1816 <div class="paragraph"><p>Binary files are searched as well.</p></div>
1817 </dd>
1818 <dt class="hdlist1">
1819 -G&lt;regex&gt;
1820 </dt>
1821 <dd>
1823 Look for differences whose patch text contains added/removed
1824 lines that match &lt;regex&gt;.
1825 </p>
1826 <div class="paragraph"><p>To illustrate the difference between <code>-S&lt;regex&gt; --pickaxe-regex</code> and
1827 <code>-G&lt;regex&gt;</code>, consider a commit with the following diff in the same
1828 file:</p></div>
1829 <div class="listingblock">
1830 <div class="content">
1831 <pre><code>+ return frotz(nitfol, two-&gt;ptr, 1, 0);
1833 - hit = frotz(nitfol, mf2.ptr, 1, 0);</code></pre>
1834 </div></div>
1835 <div class="paragraph"><p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log
1836 -S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of
1837 occurrences of that string did not change).</p></div>
1838 <div class="paragraph"><p>Unless <code>--text</code> is supplied patches of binary files without a textconv
1839 filter will be ignored.</p></div>
1840 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1841 information.</p></div>
1842 </dd>
1843 <dt class="hdlist1">
1844 --find-object=&lt;object-id&gt;
1845 </dt>
1846 <dd>
1848 Look for differences that change the number of occurrences of
1849 the specified object. Similar to <code>-S</code>, just the argument is different
1850 in that it doesn&#8217;t search for a specific string but for a specific
1851 object id.
1852 </p>
1853 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1854 <code>git-log</code> to also find trees.</p></div>
1855 </dd>
1856 <dt class="hdlist1">
1857 --pickaxe-all
1858 </dt>
1859 <dd>
1861 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1862 changeset, not just the files that contain the change
1863 in &lt;string&gt;.
1864 </p>
1865 </dd>
1866 <dt class="hdlist1">
1867 --pickaxe-regex
1868 </dt>
1869 <dd>
1871 Treat the &lt;string&gt; given to <code>-S</code> as an extended POSIX regular
1872 expression to match.
1873 </p>
1874 </dd>
1875 <dt class="hdlist1">
1876 -O&lt;orderfile&gt;
1877 </dt>
1878 <dd>
1880 Control the order in which files appear in the output.
1881 This overrides the <code>diff.orderFile</code> configuration variable
1882 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1883 use <code>-O/dev/null</code>.
1884 </p>
1885 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1886 &lt;orderfile&gt;.
1887 All files with pathnames that match the first pattern are output
1888 first, all files with pathnames that match the second pattern (but not
1889 the first) are output next, and so on.
1890 All files with pathnames that do not match any pattern are output
1891 last, as if there was an implicit match-all pattern at the end of the
1892 file.
1893 If multiple pathnames have the same rank (they match the same pattern
1894 but no earlier patterns), their output order relative to each other is
1895 the normal order.</p></div>
1896 <div class="paragraph"><p>&lt;orderfile&gt; is parsed as follows:</p></div>
1897 <div class="openblock">
1898 <div class="content">
1899 <div class="ulist"><ul>
1900 <li>
1902 Blank lines are ignored, so they can be used as separators for
1903 readability.
1904 </p>
1905 </li>
1906 <li>
1908 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1909 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1910 pattern if it starts with a hash.
1911 </p>
1912 </li>
1913 <li>
1915 Each other line contains a single pattern.
1916 </p>
1917 </li>
1918 </ul></div>
1919 </div></div>
1920 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1921 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1922 matches a pattern if removing any number of the final pathname
1923 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1924 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1925 </dd>
1926 <dt class="hdlist1">
1927 --skip-to=&lt;file&gt;
1928 </dt>
1929 <dt class="hdlist1">
1930 --rotate-to=&lt;file&gt;
1931 </dt>
1932 <dd>
1934 Discard the files before the named &lt;file&gt; from the output
1935 (i.e. <em>skip to</em>), or move them to the end of the output
1936 (i.e. <em>rotate to</em>). These were invented primarily for use
1937 of the <code>git difftool</code> command, and may not be very useful
1938 otherwise.
1939 </p>
1940 </dd>
1941 <dt class="hdlist1">
1943 </dt>
1944 <dd>
1946 Swap two inputs; that is, show differences from index or
1947 on-disk file to tree contents.
1948 </p>
1949 </dd>
1950 <dt class="hdlist1">
1951 --relative[=&lt;path&gt;]
1952 </dt>
1953 <dt class="hdlist1">
1954 --no-relative
1955 </dt>
1956 <dd>
1958 When run from a subdirectory of the project, it can be
1959 told to exclude changes outside the directory and show
1960 pathnames relative to it with this option. When you are
1961 not in a subdirectory (e.g. in a bare repository), you
1962 can name which subdirectory to make the output relative
1963 to by giving a &lt;path&gt; as an argument.
1964 <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config
1965 option and previous <code>--relative</code>.
1966 </p>
1967 </dd>
1968 <dt class="hdlist1">
1970 </dt>
1971 <dt class="hdlist1">
1972 --text
1973 </dt>
1974 <dd>
1976 Treat all files as text.
1977 </p>
1978 </dd>
1979 <dt class="hdlist1">
1980 --ignore-cr-at-eol
1981 </dt>
1982 <dd>
1984 Ignore carriage-return at the end of line when doing a comparison.
1985 </p>
1986 </dd>
1987 <dt class="hdlist1">
1988 --ignore-space-at-eol
1989 </dt>
1990 <dd>
1992 Ignore changes in whitespace at EOL.
1993 </p>
1994 </dd>
1995 <dt class="hdlist1">
1997 </dt>
1998 <dt class="hdlist1">
1999 --ignore-space-change
2000 </dt>
2001 <dd>
2003 Ignore changes in amount of whitespace. This ignores whitespace
2004 at line end, and considers all other sequences of one or
2005 more whitespace characters to be equivalent.
2006 </p>
2007 </dd>
2008 <dt class="hdlist1">
2010 </dt>
2011 <dt class="hdlist1">
2012 --ignore-all-space
2013 </dt>
2014 <dd>
2016 Ignore whitespace when comparing lines. This ignores
2017 differences even if one line has whitespace where the other
2018 line has none.
2019 </p>
2020 </dd>
2021 <dt class="hdlist1">
2022 --ignore-blank-lines
2023 </dt>
2024 <dd>
2026 Ignore changes whose lines are all blank.
2027 </p>
2028 </dd>
2029 <dt class="hdlist1">
2030 -I&lt;regex&gt;
2031 </dt>
2032 <dt class="hdlist1">
2033 --ignore-matching-lines=&lt;regex&gt;
2034 </dt>
2035 <dd>
2037 Ignore changes whose all lines match &lt;regex&gt;. This option may
2038 be specified more than once.
2039 </p>
2040 </dd>
2041 <dt class="hdlist1">
2042 --inter-hunk-context=&lt;lines&gt;
2043 </dt>
2044 <dd>
2046 Show the context between diff hunks, up to the specified number
2047 of lines, thereby fusing hunks that are close to each other.
2048 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
2049 is unset.
2050 </p>
2051 </dd>
2052 <dt class="hdlist1">
2054 </dt>
2055 <dt class="hdlist1">
2056 --function-context
2057 </dt>
2058 <dd>
2060 Show whole function as context lines for each change.
2061 The function names are determined in the same way as
2062 <code>git diff</code> works out patch hunk headers (see <em>Defining a
2063 custom hunk-header</em> in <a href="gitattributes.html">gitattributes(5)</a>).
2064 </p>
2065 </dd>
2066 <dt class="hdlist1">
2067 --exit-code
2068 </dt>
2069 <dd>
2071 Make the program exit with codes similar to diff(1).
2072 That is, it exits with 1 if there were differences and
2073 0 means no differences.
2074 </p>
2075 </dd>
2076 <dt class="hdlist1">
2077 --quiet
2078 </dt>
2079 <dd>
2081 Disable all output of the program. Implies <code>--exit-code</code>.
2082 </p>
2083 </dd>
2084 <dt class="hdlist1">
2085 --ext-diff
2086 </dt>
2087 <dd>
2089 Allow an external diff helper to be executed. If you set an
2090 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
2091 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
2092 </p>
2093 </dd>
2094 <dt class="hdlist1">
2095 --no-ext-diff
2096 </dt>
2097 <dd>
2099 Disallow external diff drivers.
2100 </p>
2101 </dd>
2102 <dt class="hdlist1">
2103 --textconv
2104 </dt>
2105 <dt class="hdlist1">
2106 --no-textconv
2107 </dt>
2108 <dd>
2110 Allow (or disallow) external text conversion filters to be run
2111 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
2112 details. Because textconv filters are typically a one-way
2113 conversion, the resulting diff is suitable for human
2114 consumption, but cannot be applied. For this reason, textconv
2115 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
2116 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
2117 diff plumbing commands.
2118 </p>
2119 </dd>
2120 <dt class="hdlist1">
2121 --ignore-submodules[=&lt;when&gt;]
2122 </dt>
2123 <dd>
2125 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
2126 either "none", "untracked", "dirty" or "all", which is the default.
2127 Using "none" will consider the submodule modified when it either contains
2128 untracked or modified files or its HEAD differs from the commit recorded
2129 in the superproject and can be used to override any settings of the
2130 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
2131 "untracked" is used submodules are not considered dirty when they only
2132 contain untracked content (but they are still scanned for modified
2133 content). Using "dirty" ignores all changes to the work tree of submodules,
2134 only changes to the commits stored in the superproject are shown (this was
2135 the behavior until 1.7.0). Using "all" hides all changes to submodules.
2136 </p>
2137 </dd>
2138 <dt class="hdlist1">
2139 --src-prefix=&lt;prefix&gt;
2140 </dt>
2141 <dd>
2143 Show the given source prefix instead of "a/".
2144 </p>
2145 </dd>
2146 <dt class="hdlist1">
2147 --dst-prefix=&lt;prefix&gt;
2148 </dt>
2149 <dd>
2151 Show the given destination prefix instead of "b/".
2152 </p>
2153 </dd>
2154 <dt class="hdlist1">
2155 --no-prefix
2156 </dt>
2157 <dd>
2159 Do not show any source or destination prefix.
2160 </p>
2161 </dd>
2162 <dt class="hdlist1">
2163 --default-prefix
2164 </dt>
2165 <dd>
2167 Use the default source and destination prefixes ("a/" and "b/").
2168 This is usually the default already, but may be used to override
2169 config such as <code>diff.noprefix</code>.
2170 </p>
2171 </dd>
2172 <dt class="hdlist1">
2173 --line-prefix=&lt;prefix&gt;
2174 </dt>
2175 <dd>
2177 Prepend an additional prefix to every line of output.
2178 </p>
2179 </dd>
2180 <dt class="hdlist1">
2181 --ita-invisible-in-index
2182 </dt>
2183 <dd>
2185 By default entries added by "git add -N" appear as an existing
2186 empty file in "git diff" and a new file in "git diff --cached".
2187 This option makes the entry appear as a new file in "git diff"
2188 and non-existent in "git diff --cached". This option could be
2189 reverted with <code>--ita-visible-in-index</code>. Both options are
2190 experimental and could be removed in future.
2191 </p>
2192 </dd>
2193 </dl></div>
2194 <div class="paragraph"><p>For more detailed explanation on these common options, see also
2195 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
2196 <div class="dlist"><dl>
2197 <dt class="hdlist1">
2198 -1 --base
2199 </dt>
2200 <dt class="hdlist1">
2201 -2 --ours
2202 </dt>
2203 <dt class="hdlist1">
2204 -3 --theirs
2205 </dt>
2206 <dd>
2208 Compare the working tree with the "base" version (stage #1),
2209 "our branch" (stage #2) or "their branch" (stage #3). The
2210 index contains these stages only for unmerged entries i.e.
2211 while resolving conflicts. See <a href="git-read-tree.html">git-read-tree(1)</a>
2212 section "3-Way Merge" for detailed information.
2213 </p>
2214 </dd>
2215 <dt class="hdlist1">
2217 </dt>
2218 <dd>
2220 Omit diff output for unmerged entries and just show
2221 "Unmerged". Can be used only when comparing the working tree
2222 with the index.
2223 </p>
2224 </dd>
2225 <dt class="hdlist1">
2226 &lt;path&gt;&#8230;
2227 </dt>
2228 <dd>
2230 The &lt;paths&gt; parameters, when given, are used to limit
2231 the diff to the named paths (you can give directory
2232 names and get diff for all files under them).
2233 </p>
2234 </dd>
2235 </dl></div>
2236 </div>
2237 </div>
2238 <div class="sect1">
2239 <h2 id="_raw_output_format">Raw output format</h2>
2240 <div class="sectionbody">
2241 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
2242 "git-diff-files" and "git diff --raw" are very similar.</p></div>
2243 <div class="paragraph"><p>These commands all compare two sets of things; what is
2244 compared differs:</p></div>
2245 <div class="dlist"><dl>
2246 <dt class="hdlist1">
2247 git-diff-index &lt;tree-ish&gt;
2248 </dt>
2249 <dd>
2251 compares the &lt;tree-ish&gt; and the files on the filesystem.
2252 </p>
2253 </dd>
2254 <dt class="hdlist1">
2255 git-diff-index --cached &lt;tree-ish&gt;
2256 </dt>
2257 <dd>
2259 compares the &lt;tree-ish&gt; and the index.
2260 </p>
2261 </dd>
2262 <dt class="hdlist1">
2263 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
2264 </dt>
2265 <dd>
2267 compares the trees named by the two arguments.
2268 </p>
2269 </dd>
2270 <dt class="hdlist1">
2271 git-diff-files [&lt;pattern&gt;&#8230;]
2272 </dt>
2273 <dd>
2275 compares the index and the files on the filesystem.
2276 </p>
2277 </dd>
2278 </dl></div>
2279 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
2280 what is being compared. After that, all the commands print one output
2281 line per changed file.</p></div>
2282 <div class="paragraph"><p>An output line is formatted this way:</p></div>
2283 <div class="listingblock">
2284 <div class="content">
2285 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
2286 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
2287 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
2288 create :000000 100644 0000000 1234567 A file4
2289 delete :100644 000000 1234567 0000000 D file5
2290 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2291 </div></div>
2292 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2293 <div class="olist arabic"><ol class="arabic">
2294 <li>
2296 a colon.
2297 </p>
2298 </li>
2299 <li>
2301 mode for "src"; 000000 if creation or unmerged.
2302 </p>
2303 </li>
2304 <li>
2306 a space.
2307 </p>
2308 </li>
2309 <li>
2311 mode for "dst"; 000000 if deletion or unmerged.
2312 </p>
2313 </li>
2314 <li>
2316 a space.
2317 </p>
2318 </li>
2319 <li>
2321 sha1 for "src"; 0{40} if creation or unmerged.
2322 </p>
2323 </li>
2324 <li>
2326 a space.
2327 </p>
2328 </li>
2329 <li>
2331 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".
2332 </p>
2333 </li>
2334 <li>
2336 a space.
2337 </p>
2338 </li>
2339 <li>
2341 status, followed by optional "score" number.
2342 </p>
2343 </li>
2344 <li>
2346 a tab or a NUL when <code>-z</code> option is used.
2347 </p>
2348 </li>
2349 <li>
2351 path for "src"
2352 </p>
2353 </li>
2354 <li>
2356 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2357 </p>
2358 </li>
2359 <li>
2361 path for "dst"; only exists for C or R.
2362 </p>
2363 </li>
2364 <li>
2366 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2367 </p>
2368 </li>
2369 </ol></div>
2370 <div class="paragraph"><p>Possible status letters are:</p></div>
2371 <div class="ulist"><ul>
2372 <li>
2374 A: addition of a file
2375 </p>
2376 </li>
2377 <li>
2379 C: copy of a file into a new one
2380 </p>
2381 </li>
2382 <li>
2384 D: deletion of a file
2385 </p>
2386 </li>
2387 <li>
2389 M: modification of the contents or mode of a file
2390 </p>
2391 </li>
2392 <li>
2394 R: renaming of a file
2395 </p>
2396 </li>
2397 <li>
2399 T: change in the type of the file (regular file, symbolic link or submodule)
2400 </p>
2401 </li>
2402 <li>
2404 U: file is unmerged (you must complete the merge before it can
2405 be committed)
2406 </p>
2407 </li>
2408 <li>
2410 X: "unknown" change type (most probably a bug, please report it)
2411 </p>
2412 </li>
2413 </ul></div>
2414 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2415 percentage of similarity between the source and target of the move or
2416 copy). Status letter M may be followed by a score (denoting the
2417 percentage of dissimilarity) for file rewrites.</p></div>
2418 <div class="paragraph"><p>The sha1 for "dst" is shown as all 0&#8217;s if a file on the filesystem
2419 is out of sync with the index.</p></div>
2420 <div class="paragraph"><p>Example:</p></div>
2421 <div class="listingblock">
2422 <div class="content">
2423 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2424 </div></div>
2425 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2426 quoted as explained for the configuration variable <code>core.quotePath</code>
2427 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2428 verbatim and the line is terminated by a NUL byte.</p></div>
2429 </div>
2430 </div>
2431 <div class="sect1">
2432 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2433 <div class="sectionbody">
2434 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2435 can take <code>-c</code> or <code>--cc</code> option
2436 to generate diff output also for merge commits. The output differs
2437 from the format described above in the following way:</p></div>
2438 <div class="olist arabic"><ol class="arabic">
2439 <li>
2441 there is a colon for each parent
2442 </p>
2443 </li>
2444 <li>
2446 there are more "src" modes and "src" sha1
2447 </p>
2448 </li>
2449 <li>
2451 status is concatenated status characters for each parent
2452 </p>
2453 </li>
2454 <li>
2456 no optional "score" number
2457 </p>
2458 </li>
2459 <li>
2461 tab-separated pathname(s) of the file
2462 </p>
2463 </li>
2464 </ol></div>
2465 <div class="paragraph"><p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even
2466 if the file was renamed on any side of history. With
2467 <code>--combined-all-paths</code>, the name of the path in each parent is shown
2468 followed by the name of the path in the merge commit.</p></div>
2469 <div class="paragraph"><p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p></div>
2470 <div class="listingblock">
2471 <div class="content">
2472 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
2473 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
2474 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</code></pre>
2475 </div></div>
2476 <div class="paragraph"><p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p></div>
2477 <div class="listingblock">
2478 <div class="content">
2479 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
2480 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2481 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</code></pre>
2482 </div></div>
2483 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2484 all parents.</p></div>
2485 </div>
2486 </div>
2487 <div class="sect1">
2488 <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2>
2489 <div class="sectionbody">
2490 <div class="paragraph"><p>Running
2491 <a href="git-diff.html">git-diff(1)</a>,
2492 <a href="git-log.html">git-log(1)</a>,
2493 <a href="git-show.html">git-show(1)</a>,
2494 <a href="git-diff-index.html">git-diff-index(1)</a>,
2495 <a href="git-diff-tree.html">git-diff-tree(1)</a>, or
2496 <a href="git-diff-files.html">git-diff-files(1)</a>
2497 with the <code>-p</code> option produces patch text.
2498 You can customize the creation of patch text via the
2499 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables
2500 (see <a href="git.html">git(1)</a>), and the <code>diff</code> attribute (see <a href="gitattributes.html">gitattributes(5)</a>).</p></div>
2501 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2502 diff format:</p></div>
2503 <div class="olist arabic"><ol class="arabic">
2504 <li>
2506 It is preceded with a "git diff" header that looks like this:
2507 </p>
2508 <div class="literalblock">
2509 <div class="content">
2510 <pre><code>diff --git a/file1 b/file2</code></pre>
2511 </div></div>
2512 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2513 involved. Especially, even for a creation or a deletion,
2514 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2515 <div class="paragraph"><p>When rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2516 name of the source file of the rename/copy and the name of
2517 the file that rename/copy produces, respectively.</p></div>
2518 </li>
2519 <li>
2521 It is followed by one or more extended header lines:
2522 </p>
2523 <div class="literalblock">
2524 <div class="content">
2525 <pre><code>old mode &lt;mode&gt;
2526 new mode &lt;mode&gt;
2527 deleted file mode &lt;mode&gt;
2528 new file mode &lt;mode&gt;
2529 copy from &lt;path&gt;
2530 copy to &lt;path&gt;
2531 rename from &lt;path&gt;
2532 rename to &lt;path&gt;
2533 similarity index &lt;number&gt;
2534 dissimilarity index &lt;number&gt;
2535 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</code></pre>
2536 </div></div>
2537 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2538 and file permission bits.</p></div>
2539 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2540 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2541 the dissimilarity index is the percentage of changed lines. It
2542 is a rounded down integer, followed by a percent sign. The
2543 similarity index value of 100% is thus reserved for two equal
2544 files, while 100% dissimilarity means that no line from the old
2545 file made it into the new one.</p></div>
2546 <div class="paragraph"><p>The index line includes the blob object names before and after the change.
2547 The &lt;mode&gt; is included if the file mode does not change; otherwise,
2548 separate lines indicate the old and the new mode.</p></div>
2549 </li>
2550 <li>
2552 Pathnames with "unusual" characters are quoted as explained for
2553 the configuration variable <code>core.quotePath</code> (see
2554 <a href="git-config.html">git-config(1)</a>).
2555 </p>
2556 </li>
2557 <li>
2559 All the <code>file1</code> files in the output refer to files before the
2560 commit, and all the <code>file2</code> files refer to files after the commit.
2561 It is incorrect to apply each change to each file sequentially. For
2562 example, this patch will swap a and b:
2563 </p>
2564 <div class="literalblock">
2565 <div class="content">
2566 <pre><code>diff --git a/a b/b
2567 rename from a
2568 rename to b
2569 diff --git a/b b/a
2570 rename from b
2571 rename to a</code></pre>
2572 </div></div>
2573 </li>
2574 <li>
2576 Hunk headers mention the name of the function to which the hunk
2577 applies. See "Defining a custom hunk-header" in
2578 <a href="gitattributes.html">gitattributes(5)</a> for details of how to tailor to this to
2579 specific languages.
2580 </p>
2581 </li>
2582 </ol></div>
2583 </div>
2584 </div>
2585 <div class="sect1">
2586 <h2 id="_combined_diff_format">Combined diff format</h2>
2587 <div class="sectionbody">
2588 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2589 produce a <em>combined diff</em> when showing a merge. This is the default
2590 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2591 <a href="git-show.html">git-show(1)</a>. Note also that you can give suitable
2592 <code>--diff-merges</code> option to any of these commands to force generation of
2593 diffs in specific format.</p></div>
2594 <div class="paragraph"><p>A "combined diff" format looks like this:</p></div>
2595 <div class="listingblock">
2596 <div class="content">
2597 <pre><code>diff --combined describe.c
2598 index fabadb8,cc95eb0..4866510
2599 --- a/describe.c
2600 +++ b/describe.c
2601 @@@ -98,20 -98,12 +98,20 @@@
2602 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2605 - static void describe(char *arg)
2606 -static void describe(struct commit *cmit, int last_one)
2607 ++static void describe(char *arg, int last_one)
2609 + unsigned char sha1[20];
2610 + struct commit *cmit;
2611 struct commit_list *list;
2612 static int initialized = 0;
2613 struct commit_name *n;
2615 + if (get_sha1(arg, sha1) &lt; 0)
2616 + usage(describe_usage);
2617 + cmit = lookup_commit_reference(sha1);
2618 + if (!cmit)
2619 + usage(describe_usage);
2621 if (!initialized) {
2622 initialized = 1;
2623 for_each_ref(get_name);</code></pre>
2624 </div></div>
2625 <div class="olist arabic"><ol class="arabic">
2626 <li>
2628 It is preceded with a "git diff" header, that looks like
2629 this (when the <code>-c</code> option is used):
2630 </p>
2631 <div class="literalblock">
2632 <div class="content">
2633 <pre><code>diff --combined file</code></pre>
2634 </div></div>
2635 <div class="paragraph"><p>or like this (when the <code>--cc</code> option is used):</p></div>
2636 <div class="literalblock">
2637 <div class="content">
2638 <pre><code>diff --cc file</code></pre>
2639 </div></div>
2640 </li>
2641 <li>
2643 It is followed by one or more extended header lines
2644 (this example shows a merge with two parents):
2645 </p>
2646 <div class="literalblock">
2647 <div class="content">
2648 <pre><code>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
2649 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
2650 new file mode &lt;mode&gt;
2651 deleted file mode &lt;mode&gt;,&lt;mode&gt;</code></pre>
2652 </div></div>
2653 <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
2654 the &lt;mode&gt; is different from the rest. Extended headers with
2655 information about detected contents movement (renames and
2656 copying detection) are designed to work with diff of two
2657 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
2658 </li>
2659 <li>
2661 It is followed by two-line from-file/to-file header
2662 </p>
2663 <div class="literalblock">
2664 <div class="content">
2665 <pre><code>--- a/file
2666 +++ b/file</code></pre>
2667 </div></div>
2668 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
2669 format, <code>/dev/null</code> is used to signal created or deleted
2670 files.</p></div>
2671 <div class="paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2672 two-line from-file/to-file you get a N+1 line from-file/to-file header,
2673 where N is the number of parents in the merge commit</p></div>
2674 <div class="literalblock">
2675 <div class="content">
2676 <pre><code>--- a/file
2677 --- a/file
2678 --- a/file
2679 +++ b/file</code></pre>
2680 </div></div>
2681 <div class="paragraph"><p>This extended format can be useful if rename or copy detection is
2682 active, to allow you to see the original name of the file in different
2683 parents.</p></div>
2684 </li>
2685 <li>
2687 Chunk header format is modified to prevent people from
2688 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2689 was created for review of merge commit changes, and was not
2690 meant to be applied. The change is similar to the change in the
2691 extended <em>index</em> header:
2692 </p>
2693 <div class="literalblock">
2694 <div class="content">
2695 <pre><code>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</code></pre>
2696 </div></div>
2697 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2698 header for combined diff format.</p></div>
2699 </li>
2700 </ol></div>
2701 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2702 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
2703 added to B), or <code>" "</code> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
2704 compares two or more files file1, file2,&#8230; with one file X, and
2705 shows how X differs from each of fileN. One column for each of
2706 fileN is prepended to the output line to note how X&#8217;s line is
2707 different from it.</p></div>
2708 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2709 fileN but it does not appear in the result. A <code>+</code> character
2710 in the column N means that the line appears in the result,
2711 and fileN does not have that line (in other words, the line was
2712 added, from the point of view of that parent).</p></div>
2713 <div class="paragraph"><p>In the above example output, the function signature was changed
2714 from both files (hence two <code>-</code> removals from both file1 and
2715 file2, plus <code>++</code> to mean one line that was added does not appear
2716 in either file1 or file2). Also eight other lines are the same
2717 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2718 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2719 merge commit with the merge result (i.e. file1..fileN are the
2720 parents). When shown by <code>git diff-files -c</code>, it compares the
2721 two unresolved merge parents with the working tree file
2722 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2723 "their version").</p></div>
2724 </div>
2725 </div>
2726 <div class="sect1">
2727 <h2 id="_other_diff_formats">other diff formats</h2>
2728 <div class="sectionbody">
2729 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2730 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2731 output. These options can be combined with other options, such as
2732 <code>-p</code>, and are meant for human consumption.</p></div>
2733 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2734 formats the pathnames compactly by combining common prefix and suffix of
2735 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2736 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2737 <div class="listingblock">
2738 <div class="content">
2739 <pre><code>arch/{i386 =&gt; x86}/Makefile | 4 +--</code></pre>
2740 </div></div>
2741 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2742 for easier machine consumption. An entry in <code>--numstat</code> output looks
2743 like this:</p></div>
2744 <div class="listingblock">
2745 <div class="content">
2746 <pre><code>1 2 README
2747 3 1 arch/{i386 =&gt; x86}/Makefile</code></pre>
2748 </div></div>
2749 <div class="paragraph"><p>That is, from left to right:</p></div>
2750 <div class="olist arabic"><ol class="arabic">
2751 <li>
2753 the number of added lines;
2754 </p>
2755 </li>
2756 <li>
2758 a tab;
2759 </p>
2760 </li>
2761 <li>
2763 the number of deleted lines;
2764 </p>
2765 </li>
2766 <li>
2768 a tab;
2769 </p>
2770 </li>
2771 <li>
2773 pathname (possibly with rename/copy information);
2774 </p>
2775 </li>
2776 <li>
2778 a newline.
2779 </p>
2780 </li>
2781 </ol></div>
2782 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2783 <div class="listingblock">
2784 <div class="content">
2785 <pre><code>1 2 README NUL
2786 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2787 </div></div>
2788 <div class="paragraph"><p>That is:</p></div>
2789 <div class="olist arabic"><ol class="arabic">
2790 <li>
2792 the number of added lines;
2793 </p>
2794 </li>
2795 <li>
2797 a tab;
2798 </p>
2799 </li>
2800 <li>
2802 the number of deleted lines;
2803 </p>
2804 </li>
2805 <li>
2807 a tab;
2808 </p>
2809 </li>
2810 <li>
2812 a NUL (only exists if renamed/copied);
2813 </p>
2814 </li>
2815 <li>
2817 pathname in preimage;
2818 </p>
2819 </li>
2820 <li>
2822 a NUL (only exists if renamed/copied);
2823 </p>
2824 </li>
2825 <li>
2827 pathname in postimage (only exists if renamed/copied);
2828 </p>
2829 </li>
2830 <li>
2832 a NUL.
2833 </p>
2834 </li>
2835 </ol></div>
2836 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2837 scripts that read the output to tell if the current record being read is
2838 a single-path record or a rename/copy record without reading ahead.
2839 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2840 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2841 </div>
2842 </div>
2843 <div class="sect1">
2844 <h2 id="_examples">EXAMPLES</h2>
2845 <div class="sectionbody">
2846 <div class="dlist"><dl>
2847 <dt class="hdlist1">
2848 Various ways to check your working tree
2849 </dt>
2850 <dd>
2851 <div class="listingblock">
2852 <div class="content">
2853 <pre><code>$ git diff <b>&lt;1&gt;</b>
2854 $ git diff --cached <b>&lt;2&gt;</b>
2855 $ git diff HEAD <b>&lt;3&gt;</b>
2856 $ git diff AUTO_MERGE <b>&lt;4&gt;</b></code></pre>
2857 </div></div>
2858 <div class="colist arabic"><ol>
2859 <li>
2861 Changes in the working tree not yet staged for the next commit.
2862 </p>
2863 </li>
2864 <li>
2866 Changes between the index and your last commit; what you
2867 would be committing if you run <code>git commit</code> without <code>-a</code> option.
2868 </p>
2869 </li>
2870 <li>
2872 Changes in the working tree since your last commit; what you
2873 would be committing if you run <code>git commit -a</code>
2874 </p>
2875 </li>
2876 <li>
2878 Changes in the working tree you&#8217;ve made to resolve textual
2879 conflicts so far.
2880 </p>
2881 </li>
2882 </ol></div>
2883 </dd>
2884 <dt class="hdlist1">
2885 Comparing with arbitrary commits
2886 </dt>
2887 <dd>
2888 <div class="listingblock">
2889 <div class="content">
2890 <pre><code>$ git diff test <b>&lt;1&gt;</b>
2891 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
2892 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></code></pre>
2893 </div></div>
2894 <div class="colist arabic"><ol>
2895 <li>
2897 Instead of using the tip of the current branch, compare with the
2898 tip of "test" branch.
2899 </p>
2900 </li>
2901 <li>
2903 Instead of comparing with the tip of "test" branch, compare with
2904 the tip of the current branch, but limit the comparison to the
2905 file "test".
2906 </p>
2907 </li>
2908 <li>
2910 Compare the version before the last commit and the last commit.
2911 </p>
2912 </li>
2913 </ol></div>
2914 </dd>
2915 <dt class="hdlist1">
2916 Comparing branches
2917 </dt>
2918 <dd>
2919 <div class="listingblock">
2920 <div class="content">
2921 <pre><code>$ git diff topic master <b>&lt;1&gt;</b>
2922 $ git diff topic..master <b>&lt;2&gt;</b>
2923 $ git diff topic...master <b>&lt;3&gt;</b></code></pre>
2924 </div></div>
2925 <div class="colist arabic"><ol>
2926 <li>
2928 Changes between the tips of the topic and the master branches.
2929 </p>
2930 </li>
2931 <li>
2933 Same as above.
2934 </p>
2935 </li>
2936 <li>
2938 Changes that occurred on the master branch since when the topic
2939 branch was started off it.
2940 </p>
2941 </li>
2942 </ol></div>
2943 </dd>
2944 <dt class="hdlist1">
2945 Limiting the diff output
2946 </dt>
2947 <dd>
2948 <div class="listingblock">
2949 <div class="content">
2950 <pre><code>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
2951 $ git diff --name-status <b>&lt;2&gt;</b>
2952 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></code></pre>
2953 </div></div>
2954 <div class="colist arabic"><ol>
2955 <li>
2957 Show only modification, rename, and copy, but not addition
2958 or deletion.
2959 </p>
2960 </li>
2961 <li>
2963 Show only names and the nature of change, but not actual
2964 diff output.
2965 </p>
2966 </li>
2967 <li>
2969 Limit diff output to named subtrees.
2970 </p>
2971 </li>
2972 </ol></div>
2973 </dd>
2974 <dt class="hdlist1">
2975 Munging the diff output
2976 </dt>
2977 <dd>
2978 <div class="listingblock">
2979 <div class="content">
2980 <pre><code>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
2981 $ git diff -R <b>&lt;2&gt;</b></code></pre>
2982 </div></div>
2983 <div class="colist arabic"><ol>
2984 <li>
2986 Spend extra cycles to find renames, copies and complete
2987 rewrites (very expensive).
2988 </p>
2989 </li>
2990 <li>
2992 Output diff in reverse.
2993 </p>
2994 </li>
2995 </ol></div>
2996 </dd>
2997 </dl></div>
2998 </div>
2999 </div>
3000 <div class="sect1">
3001 <h2 id="_configuration">CONFIGURATION</h2>
3002 <div class="sectionbody">
3003 <div class="paragraph"><p>Everything below this line in this section is selectively included
3004 from the <a href="git-config.html">git-config(1)</a> documentation. The content is the same
3005 as what&#8217;s found there:</p></div>
3006 <div class="dlist"><dl>
3007 <dt class="hdlist1">
3008 diff.autoRefreshIndex
3009 </dt>
3010 <dd>
3012 When using <em>git diff</em> to compare with work tree
3013 files, do not consider stat-only change as changed.
3014 Instead, silently run <code>git update-index --refresh</code> to
3015 update the cached stat information for paths whose
3016 contents in the work tree match the contents in the
3017 index. This option defaults to true. Note that this
3018 affects only <em>git diff</em> Porcelain, and not lower level
3019 <em>diff</em> commands such as <em>git diff-files</em>.
3020 </p>
3021 </dd>
3022 <dt class="hdlist1">
3023 diff.dirstat
3024 </dt>
3025 <dd>
3027 A comma separated list of <code>--dirstat</code> parameters specifying the
3028 default behavior of the <code>--dirstat</code> option to <a href="git-diff.html">git-diff(1)</a>
3029 and friends. The defaults can be overridden on the command line
3030 (using <code>--dirstat=&lt;param1,param2,...&gt;</code>). The fallback defaults
3031 (when not changed by <code>diff.dirstat</code>) are <code>changes,noncumulative,3</code>.
3032 The following parameters are available:
3033 </p>
3034 <div class="openblock">
3035 <div class="content">
3036 <div class="dlist"><dl>
3037 <dt class="hdlist1">
3038 <code>changes</code>
3039 </dt>
3040 <dd>
3042 Compute the dirstat numbers by counting the lines that have been
3043 removed from the source, or added to the destination. This ignores
3044 the amount of pure code movements within a file. In other words,
3045 rearranging lines in a file is not counted as much as other changes.
3046 This is the default behavior when no parameter is given.
3047 </p>
3048 </dd>
3049 <dt class="hdlist1">
3050 <code>lines</code>
3051 </dt>
3052 <dd>
3054 Compute the dirstat numbers by doing the regular line-based diff
3055 analysis, and summing the removed/added line counts. (For binary
3056 files, count 64-byte chunks instead, since binary files have no
3057 natural concept of lines). This is a more expensive <code>--dirstat</code>
3058 behavior than the <code>changes</code> behavior, but it does count rearranged
3059 lines within a file as much as other changes. The resulting output
3060 is consistent with what you get from the other <code>--*stat</code> options.
3061 </p>
3062 </dd>
3063 <dt class="hdlist1">
3064 <code>files</code>
3065 </dt>
3066 <dd>
3068 Compute the dirstat numbers by counting the number of files changed.
3069 Each changed file counts equally in the dirstat analysis. This is
3070 the computationally cheapest <code>--dirstat</code> behavior, since it does
3071 not have to look at the file contents at all.
3072 </p>
3073 </dd>
3074 <dt class="hdlist1">
3075 <code>cumulative</code>
3076 </dt>
3077 <dd>
3079 Count changes in a child directory for the parent directory as well.
3080 Note that when using <code>cumulative</code>, the sum of the percentages
3081 reported may exceed 100%. The default (non-cumulative) behavior can
3082 be specified with the <code>noncumulative</code> parameter.
3083 </p>
3084 </dd>
3085 <dt class="hdlist1">
3086 &lt;limit&gt;
3087 </dt>
3088 <dd>
3090 An integer parameter specifies a cut-off percent (3% by default).
3091 Directories contributing less than this percentage of the changes
3092 are not shown in the output.
3093 </p>
3094 </dd>
3095 </dl></div>
3096 </div></div>
3097 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
3098 directories with less than 10% of the total amount of changed files,
3099 and accumulating child directory counts in the parent directories:
3100 <code>files,10,cumulative</code>.</p></div>
3101 </dd>
3102 <dt class="hdlist1">
3103 diff.statGraphWidth
3104 </dt>
3105 <dd>
3107 Limit the width of the graph part in --stat output. If set, applies
3108 to all commands generating --stat output except format-patch.
3109 </p>
3110 </dd>
3111 <dt class="hdlist1">
3112 diff.context
3113 </dt>
3114 <dd>
3116 Generate diffs with &lt;n&gt; lines of context instead of the default
3117 of 3. This value is overridden by the -U option.
3118 </p>
3119 </dd>
3120 <dt class="hdlist1">
3121 diff.interHunkContext
3122 </dt>
3123 <dd>
3125 Show the context between diff hunks, up to the specified number
3126 of lines, thereby fusing the hunks that are close to each other.
3127 This value serves as the default for the <code>--inter-hunk-context</code>
3128 command line option.
3129 </p>
3130 </dd>
3131 <dt class="hdlist1">
3132 diff.external
3133 </dt>
3134 <dd>
3136 If this config variable is set, diff generation is not
3137 performed using the internal diff machinery, but using the
3138 given command. Can be overridden with the &#8216;GIT_EXTERNAL_DIFF&#8217;
3139 environment variable. The command is called with parameters
3140 as described under "git Diffs" in <a href="git.html">git(1)</a>. Note: if
3141 you want to use an external diff program only on a subset of
3142 your files, you might want to use <a href="gitattributes.html">gitattributes(5)</a> instead.
3143 </p>
3144 </dd>
3145 <dt class="hdlist1">
3146 diff.ignoreSubmodules
3147 </dt>
3148 <dd>
3150 Sets the default value of --ignore-submodules. Note that this
3151 affects only <em>git diff</em> Porcelain, and not lower level <em>diff</em>
3152 commands such as <em>git diff-files</em>. <em>git checkout</em>
3153 and <em>git switch</em> also honor
3154 this setting when reporting uncommitted changes. Setting it to
3155 <em>all</em> disables the submodule summary normally shown by <em>git commit</em>
3156 and <em>git status</em> when <code>status.submoduleSummary</code> is set unless it is
3157 overridden by using the --ignore-submodules command-line option.
3158 The <em>git submodule</em> commands are not affected by this setting.
3159 By default this is set to untracked so that any untracked
3160 submodules are ignored.
3161 </p>
3162 </dd>
3163 <dt class="hdlist1">
3164 diff.mnemonicPrefix
3165 </dt>
3166 <dd>
3168 If set, <em>git diff</em> uses a prefix pair that is different from the
3169 standard "a/" and "b/" depending on what is being compared. When
3170 this configuration is in effect, reverse diff output also swaps
3171 the order of the prefixes:
3172 </p>
3173 <div class="dlist"><dl>
3174 <dt class="hdlist1">
3175 <code>git diff</code>
3176 </dt>
3177 <dd>
3179 compares the (i)ndex and the (w)ork tree;
3180 </p>
3181 </dd>
3182 <dt class="hdlist1">
3183 <code>git diff HEAD</code>
3184 </dt>
3185 <dd>
3187 compares a (c)ommit and the (w)ork tree;
3188 </p>
3189 </dd>
3190 <dt class="hdlist1">
3191 <code>git diff --cached</code>
3192 </dt>
3193 <dd>
3195 compares a (c)ommit and the (i)ndex;
3196 </p>
3197 </dd>
3198 <dt class="hdlist1">
3199 <code>git diff HEAD:file1 file2</code>
3200 </dt>
3201 <dd>
3203 compares an (o)bject and a (w)ork tree entity;
3204 </p>
3205 </dd>
3206 <dt class="hdlist1">
3207 <code>git diff --no-index a b</code>
3208 </dt>
3209 <dd>
3211 compares two non-git things (1) and (2).
3212 </p>
3213 </dd>
3214 </dl></div>
3215 </dd>
3216 <dt class="hdlist1">
3217 diff.noprefix
3218 </dt>
3219 <dd>
3221 If set, <em>git diff</em> does not show any source or destination prefix.
3222 </p>
3223 </dd>
3224 <dt class="hdlist1">
3225 diff.relative
3226 </dt>
3227 <dd>
3229 If set to <em>true</em>, <em>git diff</em> does not show changes outside of the directory
3230 and show pathnames relative to the current directory.
3231 </p>
3232 </dd>
3233 <dt class="hdlist1">
3234 diff.orderFile
3235 </dt>
3236 <dd>
3238 File indicating how to order files within a diff.
3239 See the <em>-O</em> option to <a href="git-diff.html">git-diff(1)</a> for details.
3240 If <code>diff.orderFile</code> is a relative pathname, it is treated as
3241 relative to the top of the working tree.
3242 </p>
3243 </dd>
3244 <dt class="hdlist1">
3245 diff.renameLimit
3246 </dt>
3247 <dd>
3249 The number of files to consider in the exhaustive portion of
3250 copy/rename detection; equivalent to the <em>git diff</em> option
3251 <code>-l</code>. If not set, the default value is currently 1000. This
3252 setting has no effect if rename detection is turned off.
3253 </p>
3254 </dd>
3255 <dt class="hdlist1">
3256 diff.renames
3257 </dt>
3258 <dd>
3260 Whether and how Git detects renames. If set to "false",
3261 rename detection is disabled. If set to "true", basic rename
3262 detection is enabled. If set to "copies" or "copy", Git will
3263 detect copies, as well. Defaults to true. Note that this
3264 affects only <em>git diff</em> Porcelain like <a href="git-diff.html">git-diff(1)</a> and
3265 <a href="git-log.html">git-log(1)</a>, and not lower level commands such as
3266 <a href="git-diff-files.html">git-diff-files(1)</a>.
3267 </p>
3268 </dd>
3269 <dt class="hdlist1">
3270 diff.suppressBlankEmpty
3271 </dt>
3272 <dd>
3274 A boolean to inhibit the standard behavior of printing a space
3275 before each empty output line. Defaults to false.
3276 </p>
3277 </dd>
3278 <dt class="hdlist1">
3279 diff.submodule
3280 </dt>
3281 <dd>
3283 Specify the format in which differences in submodules are
3284 shown. The "short" format just shows the names of the commits
3285 at the beginning and end of the range. The "log" format lists
3286 the commits in the range like <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code>
3287 does. The "diff" format shows an inline diff of the changed
3288 contents of the submodule. Defaults to "short".
3289 </p>
3290 </dd>
3291 <dt class="hdlist1">
3292 diff.wordRegex
3293 </dt>
3294 <dd>
3296 A POSIX Extended Regular Expression used to determine what is a "word"
3297 when performing word-by-word difference calculations. Character
3298 sequences that match the regular expression are "words", all other
3299 characters are <strong>ignorable</strong> whitespace.
3300 </p>
3301 </dd>
3302 <dt class="hdlist1">
3303 diff.&lt;driver&gt;.command
3304 </dt>
3305 <dd>
3307 The custom diff driver command. See <a href="gitattributes.html">gitattributes(5)</a>
3308 for details.
3309 </p>
3310 </dd>
3311 <dt class="hdlist1">
3312 diff.&lt;driver&gt;.xfuncname
3313 </dt>
3314 <dd>
3316 The regular expression that the diff driver should use to
3317 recognize the hunk header. A built-in pattern may also be used.
3318 See <a href="gitattributes.html">gitattributes(5)</a> for details.
3319 </p>
3320 </dd>
3321 <dt class="hdlist1">
3322 diff.&lt;driver&gt;.binary
3323 </dt>
3324 <dd>
3326 Set this option to true to make the diff driver treat files as
3327 binary. See <a href="gitattributes.html">gitattributes(5)</a> for details.
3328 </p>
3329 </dd>
3330 <dt class="hdlist1">
3331 diff.&lt;driver&gt;.textconv
3332 </dt>
3333 <dd>
3335 The command that the diff driver should call to generate the
3336 text-converted version of a file. The result of the
3337 conversion is used to generate a human-readable diff. See
3338 <a href="gitattributes.html">gitattributes(5)</a> for details.
3339 </p>
3340 </dd>
3341 <dt class="hdlist1">
3342 diff.&lt;driver&gt;.wordRegex
3343 </dt>
3344 <dd>
3346 The regular expression that the diff driver should use to
3347 split words in a line. See <a href="gitattributes.html">gitattributes(5)</a> for
3348 details.
3349 </p>
3350 </dd>
3351 <dt class="hdlist1">
3352 diff.&lt;driver&gt;.cachetextconv
3353 </dt>
3354 <dd>
3356 Set this option to true to make the diff driver cache the text
3357 conversion outputs. See <a href="gitattributes.html">gitattributes(5)</a> for details.
3358 </p>
3359 <div class="dlist"><dl>
3360 <dt class="hdlist1">
3361 <code>araxis</code>
3362 </dt>
3363 <dd>
3365 Use Araxis Merge (requires a graphical session)
3366 </p>
3367 </dd>
3368 <dt class="hdlist1">
3369 <code>bc</code>
3370 </dt>
3371 <dd>
3373 Use Beyond Compare (requires a graphical session)
3374 </p>
3375 </dd>
3376 <dt class="hdlist1">
3377 <code>bc3</code>
3378 </dt>
3379 <dd>
3381 Use Beyond Compare (requires a graphical session)
3382 </p>
3383 </dd>
3384 <dt class="hdlist1">
3385 <code>bc4</code>
3386 </dt>
3387 <dd>
3389 Use Beyond Compare (requires a graphical session)
3390 </p>
3391 </dd>
3392 <dt class="hdlist1">
3393 <code>codecompare</code>
3394 </dt>
3395 <dd>
3397 Use Code Compare (requires a graphical session)
3398 </p>
3399 </dd>
3400 <dt class="hdlist1">
3401 <code>deltawalker</code>
3402 </dt>
3403 <dd>
3405 Use DeltaWalker (requires a graphical session)
3406 </p>
3407 </dd>
3408 <dt class="hdlist1">
3409 <code>diffmerge</code>
3410 </dt>
3411 <dd>
3413 Use DiffMerge (requires a graphical session)
3414 </p>
3415 </dd>
3416 <dt class="hdlist1">
3417 <code>diffuse</code>
3418 </dt>
3419 <dd>
3421 Use Diffuse (requires a graphical session)
3422 </p>
3423 </dd>
3424 <dt class="hdlist1">
3425 <code>ecmerge</code>
3426 </dt>
3427 <dd>
3429 Use ECMerge (requires a graphical session)
3430 </p>
3431 </dd>
3432 <dt class="hdlist1">
3433 <code>emerge</code>
3434 </dt>
3435 <dd>
3437 Use Emacs' Emerge
3438 </p>
3439 </dd>
3440 <dt class="hdlist1">
3441 <code>examdiff</code>
3442 </dt>
3443 <dd>
3445 Use ExamDiff Pro (requires a graphical session)
3446 </p>
3447 </dd>
3448 <dt class="hdlist1">
3449 <code>guiffy</code>
3450 </dt>
3451 <dd>
3453 Use Guiffy&#8217;s Diff Tool (requires a graphical session)
3454 </p>
3455 </dd>
3456 <dt class="hdlist1">
3457 <code>gvimdiff</code>
3458 </dt>
3459 <dd>
3461 Use gVim (requires a graphical session)
3462 </p>
3463 </dd>
3464 <dt class="hdlist1">
3465 <code>kdiff3</code>
3466 </dt>
3467 <dd>
3469 Use KDiff3 (requires a graphical session)
3470 </p>
3471 </dd>
3472 <dt class="hdlist1">
3473 <code>kompare</code>
3474 </dt>
3475 <dd>
3477 Use Kompare (requires a graphical session)
3478 </p>
3479 </dd>
3480 <dt class="hdlist1">
3481 <code>meld</code>
3482 </dt>
3483 <dd>
3485 Use Meld (requires a graphical session)
3486 </p>
3487 </dd>
3488 <dt class="hdlist1">
3489 <code>nvimdiff</code>
3490 </dt>
3491 <dd>
3493 Use Neovim
3494 </p>
3495 </dd>
3496 <dt class="hdlist1">
3497 <code>opendiff</code>
3498 </dt>
3499 <dd>
3501 Use FileMerge (requires a graphical session)
3502 </p>
3503 </dd>
3504 <dt class="hdlist1">
3505 <code>p4merge</code>
3506 </dt>
3507 <dd>
3509 Use HelixCore P4Merge (requires a graphical session)
3510 </p>
3511 </dd>
3512 <dt class="hdlist1">
3513 <code>smerge</code>
3514 </dt>
3515 <dd>
3517 Use Sublime Merge (requires a graphical session)
3518 </p>
3519 </dd>
3520 <dt class="hdlist1">
3521 <code>tkdiff</code>
3522 </dt>
3523 <dd>
3525 Use TkDiff (requires a graphical session)
3526 </p>
3527 </dd>
3528 <dt class="hdlist1">
3529 <code>vimdiff</code>
3530 </dt>
3531 <dd>
3533 Use Vim
3534 </p>
3535 </dd>
3536 <dt class="hdlist1">
3537 <code>winmerge</code>
3538 </dt>
3539 <dd>
3541 Use WinMerge (requires a graphical session)
3542 </p>
3543 </dd>
3544 <dt class="hdlist1">
3545 <code>xxdiff</code>
3546 </dt>
3547 <dd>
3549 Use xxdiff (requires a graphical session)
3550 </p>
3551 </dd>
3552 </dl></div>
3553 </dd>
3554 <dt class="hdlist1">
3555 diff.indentHeuristic
3556 </dt>
3557 <dd>
3559 Set this option to <code>false</code> to disable the default heuristics
3560 that shift diff hunk boundaries to make patches easier to read.
3561 </p>
3562 </dd>
3563 <dt class="hdlist1">
3564 diff.algorithm
3565 </dt>
3566 <dd>
3568 Choose a diff algorithm. The variants are as follows:
3569 </p>
3570 <div class="openblock">
3571 <div class="content">
3572 <div class="dlist"><dl>
3573 <dt class="hdlist1">
3574 <code>default</code>, <code>myers</code>
3575 </dt>
3576 <dd>
3578 The basic greedy diff algorithm. Currently, this is the default.
3579 </p>
3580 </dd>
3581 <dt class="hdlist1">
3582 <code>minimal</code>
3583 </dt>
3584 <dd>
3586 Spend extra time to make sure the smallest possible diff is
3587 produced.
3588 </p>
3589 </dd>
3590 <dt class="hdlist1">
3591 <code>patience</code>
3592 </dt>
3593 <dd>
3595 Use "patience diff" algorithm when generating patches.
3596 </p>
3597 </dd>
3598 <dt class="hdlist1">
3599 <code>histogram</code>
3600 </dt>
3601 <dd>
3603 This algorithm extends the patience algorithm to "support
3604 low-occurrence common elements".
3605 </p>
3606 </dd>
3607 </dl></div>
3608 </div></div>
3609 </dd>
3610 <dt class="hdlist1">
3611 diff.wsErrorHighlight
3612 </dt>
3613 <dd>
3615 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
3616 lines of the diff. Multiple values are separated by comma,
3617 <code>none</code> resets previous values, <code>default</code> reset the list to
3618 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. The
3619 whitespace errors are colored with <code>color.diff.whitespace</code>.
3620 The command line option <code>--ws-error-highlight=&lt;kind&gt;</code>
3621 overrides this setting.
3622 </p>
3623 </dd>
3624 <dt class="hdlist1">
3625 diff.colorMoved
3626 </dt>
3627 <dd>
3629 If set to either a valid <code>&lt;mode&gt;</code> or a true value, moved lines
3630 in a diff are colored differently, for details of valid modes
3631 see <em>--color-moved</em> in <a href="git-diff.html">git-diff(1)</a>. If simply set to
3632 true the default color mode will be used. When set to false,
3633 moved lines are not colored.
3634 </p>
3635 </dd>
3636 <dt class="hdlist1">
3637 diff.colorMovedWS
3638 </dt>
3639 <dd>
3641 When moved lines are colored using e.g. the <code>diff.colorMoved</code> setting,
3642 this option controls the <code>&lt;mode&gt;</code> how spaces are treated
3643 for details of valid modes see <em>--color-moved-ws</em> in <a href="git-diff.html">git-diff(1)</a>.
3644 </p>
3645 </dd>
3646 </dl></div>
3647 </div>
3648 </div>
3649 <div class="sect1">
3650 <h2 id="_see_also">SEE ALSO</h2>
3651 <div class="sectionbody">
3652 <div class="paragraph"><p>diff(1),
3653 <a href="git-difftool.html">git-difftool(1)</a>,
3654 <a href="git-log.html">git-log(1)</a>,
3655 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
3656 <a href="git-format-patch.html">git-format-patch(1)</a>,
3657 <a href="git-apply.html">git-apply(1)</a>,
3658 <a href="git-show.html">git-show(1)</a></p></div>
3659 </div>
3660 </div>
3661 <div class="sect1">
3662 <h2 id="_git">GIT</h2>
3663 <div class="sectionbody">
3664 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
3665 </div>
3666 </div>
3667 </div>
3668 <div id="footnotes"><hr /></div>
3669 <div id="footer">
3670 <div id="footer-text">
3671 Last updated
3672 2023-06-23 13:24:09 PDT
3673 </div>
3674 </div>
3675 </body>
3676 </html>