Autogenerated HTML docs for v2.45.1-313-g3a57a
[git-htmldocs.git] / git-diff.html
blob84d24cc9aa2349e292a5217b2884d6e03503aaf9
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 ref named <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 or by setting
1105 <code>diff.statNameWidth=&lt;width&gt;</code>. The width of the graph part can be
1106 limited by using <code>--stat-graph-width=&lt;width&gt;</code> or by setting
1107 <code>diff.statGraphWidth=&lt;width&gt;</code>. Using <code>--stat</code> or
1108 <code>--stat-graph-width</code> affects all commands generating a stat graph,
1109 while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code>
1110 does not affect <code>git format-patch</code>.
1111 By giving a third parameter <code>&lt;count&gt;</code>, you can limit the output to
1112 the first <code>&lt;count&gt;</code> lines, followed by <code>...</code> if there are more.
1113 </p>
1114 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=&lt;width&gt;</code>,
1115 <code>--stat-name-width=&lt;name-width&gt;</code> and <code>--stat-count=&lt;count&gt;</code>.</p></div>
1116 </dd>
1117 <dt class="hdlist1">
1118 --compact-summary
1119 </dt>
1120 <dd>
1122 Output a condensed summary of extended header information such
1123 as file creations or deletions ("new" or "gone", optionally "+l"
1124 if it&#8217;s a symlink) and mode changes ("+x" or "-x" for adding
1125 or removing executable bit respectively) in diffstat. The
1126 information is put between the filename part and the graph
1127 part. Implies <code>--stat</code>.
1128 </p>
1129 </dd>
1130 <dt class="hdlist1">
1131 --numstat
1132 </dt>
1133 <dd>
1135 Similar to <code>--stat</code>, but shows number of added and
1136 deleted lines in decimal notation and pathname without
1137 abbreviation, to make it more machine friendly. For
1138 binary files, outputs two <code>-</code> instead of saying
1139 <code>0 0</code>.
1140 </p>
1141 </dd>
1142 <dt class="hdlist1">
1143 --shortstat
1144 </dt>
1145 <dd>
1147 Output only the last line of the <code>--stat</code> format containing total
1148 number of modified files, as well as number of added and deleted
1149 lines.
1150 </p>
1151 </dd>
1152 <dt class="hdlist1">
1153 -X[&lt;param1,param2,&#8230;&gt;]
1154 </dt>
1155 <dt class="hdlist1">
1156 --dirstat[=&lt;param1,param2,&#8230;&gt;]
1157 </dt>
1158 <dd>
1160 Output the distribution of relative amount of changes for each
1161 sub-directory. The behavior of <code>--dirstat</code> can be customized by
1162 passing it a comma separated list of parameters.
1163 The defaults are controlled by the <code>diff.dirstat</code> configuration
1164 variable (see <a href="git-config.html">git-config(1)</a>).
1165 The following parameters are available:
1166 </p>
1167 <div class="openblock">
1168 <div class="content">
1169 <div class="dlist"><dl>
1170 <dt class="hdlist1">
1171 <code>changes</code>
1172 </dt>
1173 <dd>
1175 Compute the dirstat numbers by counting the lines that have been
1176 removed from the source, or added to the destination. This ignores
1177 the amount of pure code movements within a file. In other words,
1178 rearranging lines in a file is not counted as much as other changes.
1179 This is the default behavior when no parameter is given.
1180 </p>
1181 </dd>
1182 <dt class="hdlist1">
1183 <code>lines</code>
1184 </dt>
1185 <dd>
1187 Compute the dirstat numbers by doing the regular line-based diff
1188 analysis, and summing the removed/added line counts. (For binary
1189 files, count 64-byte chunks instead, since binary files have no
1190 natural concept of lines). This is a more expensive <code>--dirstat</code>
1191 behavior than the <code>changes</code> behavior, but it does count rearranged
1192 lines within a file as much as other changes. The resulting output
1193 is consistent with what you get from the other <code>--*stat</code> options.
1194 </p>
1195 </dd>
1196 <dt class="hdlist1">
1197 <code>files</code>
1198 </dt>
1199 <dd>
1201 Compute the dirstat numbers by counting the number of files changed.
1202 Each changed file counts equally in the dirstat analysis. This is
1203 the computationally cheapest <code>--dirstat</code> behavior, since it does
1204 not have to look at the file contents at all.
1205 </p>
1206 </dd>
1207 <dt class="hdlist1">
1208 <code>cumulative</code>
1209 </dt>
1210 <dd>
1212 Count changes in a child directory for the parent directory as well.
1213 Note that when using <code>cumulative</code>, the sum of the percentages
1214 reported may exceed 100%. The default (non-cumulative) behavior can
1215 be specified with the <code>noncumulative</code> parameter.
1216 </p>
1217 </dd>
1218 <dt class="hdlist1">
1219 &lt;limit&gt;
1220 </dt>
1221 <dd>
1223 An integer parameter specifies a cut-off percent (3% by default).
1224 Directories contributing less than this percentage of the changes
1225 are not shown in the output.
1226 </p>
1227 </dd>
1228 </dl></div>
1229 </div></div>
1230 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1231 directories with less than 10% of the total amount of changed files,
1232 and accumulating child directory counts in the parent directories:
1233 <code>--dirstat=files,10,cumulative</code>.</p></div>
1234 </dd>
1235 <dt class="hdlist1">
1236 --cumulative
1237 </dt>
1238 <dd>
1240 Synonym for --dirstat=cumulative
1241 </p>
1242 </dd>
1243 <dt class="hdlist1">
1244 --dirstat-by-file[=&lt;param1,param2&gt;&#8230;]
1245 </dt>
1246 <dd>
1248 Synonym for --dirstat=files,&lt;param1&gt;,&lt;param2&gt;&#8230;
1249 </p>
1250 </dd>
1251 <dt class="hdlist1">
1252 --summary
1253 </dt>
1254 <dd>
1256 Output a condensed summary of extended header information
1257 such as creations, renames and mode changes.
1258 </p>
1259 </dd>
1260 <dt class="hdlist1">
1261 --patch-with-stat
1262 </dt>
1263 <dd>
1265 Synonym for <code>-p --stat</code>.
1266 </p>
1267 </dd>
1268 <dt class="hdlist1">
1270 </dt>
1271 <dd>
1273 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1274 given, do not munge pathnames and use NULs as output field terminators.
1275 </p>
1276 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1277 explained for the configuration variable <code>core.quotePath</code> (see
1278 <a href="git-config.html">git-config(1)</a>).</p></div>
1279 </dd>
1280 <dt class="hdlist1">
1281 --name-only
1282 </dt>
1283 <dd>
1285 Show only the name of each changed file in the post-image tree.
1286 The file names are often encoded in UTF-8.
1287 For more information see the discussion about encoding in the <a href="git-log.html">git-log(1)</a>
1288 manual page.
1289 </p>
1290 </dd>
1291 <dt class="hdlist1">
1292 --name-status
1293 </dt>
1294 <dd>
1296 Show only the name(s) and status of each changed file. See the description
1297 of the <code>--diff-filter</code> option on what the status letters mean.
1298 Just like <code>--name-only</code> the file names are often encoded in UTF-8.
1299 </p>
1300 </dd>
1301 <dt class="hdlist1">
1302 --submodule[=&lt;format&gt;]
1303 </dt>
1304 <dd>
1306 Specify how differences in submodules are shown. When specifying
1307 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1308 shows the names of the commits at the beginning and end of the range.
1309 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1310 format is used. This format lists the commits in the range like
1311 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1312 is specified, the <em>diff</em> format is used. This format shows an
1313 inline diff of the changes in the submodule contents between the
1314 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1315 if the config option is unset.
1316 </p>
1317 </dd>
1318 <dt class="hdlist1">
1319 --color[=&lt;when&gt;]
1320 </dt>
1321 <dd>
1323 Show colored diff.
1324 <code>--color</code> (i.e. without <em>=&lt;when&gt;</em>) is the same as <code>--color=always</code>.
1325 <em>&lt;when&gt;</em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1326 It can be changed by the <code>color.ui</code> and <code>color.diff</code>
1327 configuration settings.
1328 </p>
1329 </dd>
1330 <dt class="hdlist1">
1331 --no-color
1332 </dt>
1333 <dd>
1335 Turn off colored diff.
1336 This can be used to override configuration settings.
1337 It is the same as <code>--color=never</code>.
1338 </p>
1339 </dd>
1340 <dt class="hdlist1">
1341 --color-moved[=&lt;mode&gt;]
1342 </dt>
1343 <dd>
1345 Moved lines of code are colored differently.
1346 It can be changed by the <code>diff.colorMoved</code> configuration setting.
1347 The &lt;mode&gt; defaults to <em>no</em> if the option is not given
1348 and to <em>zebra</em> if the option with no mode is given.
1349 The mode must be one of:
1350 </p>
1351 <div class="openblock">
1352 <div class="content">
1353 <div class="dlist"><dl>
1354 <dt class="hdlist1">
1356 </dt>
1357 <dd>
1359 Moved lines are not highlighted.
1360 </p>
1361 </dd>
1362 <dt class="hdlist1">
1363 default
1364 </dt>
1365 <dd>
1367 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1368 in the future.
1369 </p>
1370 </dd>
1371 <dt class="hdlist1">
1372 plain
1373 </dt>
1374 <dd>
1376 Any line that is added in one location and was removed
1377 in another location will be colored with <em>color.diff.newMoved</em>.
1378 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1379 that are added somewhere else in the diff. This mode picks up any
1380 moved line, but it is not very useful in a review to determine
1381 if a block of code was moved without permutation.
1382 </p>
1383 </dd>
1384 <dt class="hdlist1">
1385 blocks
1386 </dt>
1387 <dd>
1389 Blocks of moved text of at least 20 alphanumeric characters
1390 are detected greedily. The detected blocks are
1391 painted using either the <em>color.diff.{old,new}Moved</em> color.
1392 Adjacent blocks cannot be told apart.
1393 </p>
1394 </dd>
1395 <dt class="hdlist1">
1396 zebra
1397 </dt>
1398 <dd>
1400 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1401 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1402 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1403 the two colors indicates that a new block was detected.
1404 </p>
1405 </dd>
1406 <dt class="hdlist1">
1407 dimmed-zebra
1408 </dt>
1409 <dd>
1411 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1412 of moved code is performed. The bordering lines of two adjacent
1413 blocks are considered interesting, the rest is uninteresting.
1414 <code>dimmed_zebra</code> is a deprecated synonym.
1415 </p>
1416 </dd>
1417 </dl></div>
1418 </div></div>
1419 </dd>
1420 <dt class="hdlist1">
1421 --no-color-moved
1422 </dt>
1423 <dd>
1425 Turn off move detection. This can be used to override configuration
1426 settings. It is the same as <code>--color-moved=no</code>.
1427 </p>
1428 </dd>
1429 <dt class="hdlist1">
1430 --color-moved-ws=&lt;modes&gt;
1431 </dt>
1432 <dd>
1434 This configures how whitespace is ignored when performing the
1435 move detection for <code>--color-moved</code>.
1436 It can be set by the <code>diff.colorMovedWS</code> configuration setting.
1437 These modes can be given as a comma separated list:
1438 </p>
1439 <div class="openblock">
1440 <div class="content">
1441 <div class="dlist"><dl>
1442 <dt class="hdlist1">
1444 </dt>
1445 <dd>
1447 Do not ignore whitespace when performing move detection.
1448 </p>
1449 </dd>
1450 <dt class="hdlist1">
1451 ignore-space-at-eol
1452 </dt>
1453 <dd>
1455 Ignore changes in whitespace at EOL.
1456 </p>
1457 </dd>
1458 <dt class="hdlist1">
1459 ignore-space-change
1460 </dt>
1461 <dd>
1463 Ignore changes in amount of whitespace. This ignores whitespace
1464 at line end, and considers all other sequences of one or
1465 more whitespace characters to be equivalent.
1466 </p>
1467 </dd>
1468 <dt class="hdlist1">
1469 ignore-all-space
1470 </dt>
1471 <dd>
1473 Ignore whitespace when comparing lines. This ignores differences
1474 even if one line has whitespace where the other line has none.
1475 </p>
1476 </dd>
1477 <dt class="hdlist1">
1478 allow-indentation-change
1479 </dt>
1480 <dd>
1482 Initially ignore any whitespace in the move detection, then
1483 group the moved code blocks only into a block if the change in
1484 whitespace is the same per line. This is incompatible with the
1485 other modes.
1486 </p>
1487 </dd>
1488 </dl></div>
1489 </div></div>
1490 </dd>
1491 <dt class="hdlist1">
1492 --no-color-moved-ws
1493 </dt>
1494 <dd>
1496 Do not ignore whitespace when performing move detection. This can be
1497 used to override configuration settings. It is the same as
1498 <code>--color-moved-ws=no</code>.
1499 </p>
1500 </dd>
1501 <dt class="hdlist1">
1502 --word-diff[=&lt;mode&gt;]
1503 </dt>
1504 <dd>
1506 Show a word diff, using the &lt;mode&gt; to delimit changed words.
1507 By default, words are delimited by whitespace; see
1508 <code>--word-diff-regex</code> below. The &lt;mode&gt; defaults to <em>plain</em>, and
1509 must be one of:
1510 </p>
1511 <div class="openblock">
1512 <div class="content">
1513 <div class="dlist"><dl>
1514 <dt class="hdlist1">
1515 color
1516 </dt>
1517 <dd>
1519 Highlight changed words using only colors. Implies <code>--color</code>.
1520 </p>
1521 </dd>
1522 <dt class="hdlist1">
1523 plain
1524 </dt>
1525 <dd>
1527 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1528 attempts to escape the delimiters if they appear in the input,
1529 so the output may be ambiguous.
1530 </p>
1531 </dd>
1532 <dt class="hdlist1">
1533 porcelain
1534 </dt>
1535 <dd>
1537 Use a special line-based format intended for script
1538 consumption. Added/removed/unchanged runs are printed in the
1539 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1540 character at the beginning of the line and extending to the
1541 end of the line. Newlines in the input are represented by a
1542 tilde <code>~</code> on a line of its own.
1543 </p>
1544 </dd>
1545 <dt class="hdlist1">
1546 none
1547 </dt>
1548 <dd>
1550 Disable word diff again.
1551 </p>
1552 </dd>
1553 </dl></div>
1554 </div></div>
1555 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1556 highlight the changed parts in all modes if enabled.</p></div>
1557 </dd>
1558 <dt class="hdlist1">
1559 --word-diff-regex=&lt;regex&gt;
1560 </dt>
1561 <dd>
1563 Use &lt;regex&gt; to decide what a word is, instead of considering
1564 runs of non-whitespace to be a word. Also implies
1565 <code>--word-diff</code> unless it was already enabled.
1566 </p>
1567 <div class="paragraph"><p>Every non-overlapping match of the
1568 &lt;regex&gt; is considered a word. Anything between these matches is
1569 considered whitespace and ignored(!) for the purposes of finding
1570 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1571 expression to make sure that it matches all non-whitespace characters.
1572 A match that contains a newline is silently truncated(!) at the
1573 newline.</p></div>
1574 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1575 and, correspondingly, show differences character by character.</p></div>
1576 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1577 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1578 overrides any diff driver or configuration setting. Diff drivers
1579 override configuration settings.</p></div>
1580 </dd>
1581 <dt class="hdlist1">
1582 --color-words[=&lt;regex&gt;]
1583 </dt>
1584 <dd>
1586 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1587 specified) <code>--word-diff-regex=&lt;regex&gt;</code>.
1588 </p>
1589 </dd>
1590 <dt class="hdlist1">
1591 --no-renames
1592 </dt>
1593 <dd>
1595 Turn off rename detection, even when the configuration
1596 file gives the default to do so.
1597 </p>
1598 </dd>
1599 <dt class="hdlist1">
1600 --[no-]rename-empty
1601 </dt>
1602 <dd>
1604 Whether to use empty blobs as rename source.
1605 </p>
1606 </dd>
1607 <dt class="hdlist1">
1608 --check
1609 </dt>
1610 <dd>
1612 Warn if changes introduce conflict markers or whitespace errors.
1613 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1614 configuration. By default, trailing whitespaces (including
1615 lines that consist solely of whitespaces) and a space character
1616 that is immediately followed by a tab character inside the
1617 initial indent of the line are considered whitespace errors.
1618 Exits with non-zero status if problems are found. Not compatible
1619 with --exit-code.
1620 </p>
1621 </dd>
1622 <dt class="hdlist1">
1623 --ws-error-highlight=&lt;kind&gt;
1624 </dt>
1625 <dd>
1627 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1628 lines of the diff. Multiple values are separated by comma,
1629 <code>none</code> resets previous values, <code>default</code> reset the list to
1630 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1631 this option is not given, and the configuration variable
1632 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1633 <code>new</code> lines are highlighted. The whitespace errors are colored
1634 with <code>color.diff.whitespace</code>.
1635 </p>
1636 </dd>
1637 <dt class="hdlist1">
1638 --full-index
1639 </dt>
1640 <dd>
1642 Instead of the first handful of characters, show the full
1643 pre- and post-image blob object names on the "index"
1644 line when generating patch format output.
1645 </p>
1646 </dd>
1647 <dt class="hdlist1">
1648 --binary
1649 </dt>
1650 <dd>
1652 In addition to <code>--full-index</code>, output a binary diff that
1653 can be applied with <code>git-apply</code>.
1654 Implies <code>--patch</code>.
1655 </p>
1656 </dd>
1657 <dt class="hdlist1">
1658 --abbrev[=&lt;n&gt;]
1659 </dt>
1660 <dd>
1662 Instead of showing the full 40-byte hexadecimal object
1663 name in diff-raw format output and diff-tree header
1664 lines, show the shortest prefix that is at least <em>&lt;n&gt;</em>
1665 hexdigits long that uniquely refers the object.
1666 In diff-patch output format, <code>--full-index</code> takes higher
1667 precedence, i.e. if <code>--full-index</code> is specified, full blob
1668 names will be shown regardless of <code>--abbrev</code>.
1669 Non default number of digits can be specified with <code>--abbrev=&lt;n&gt;</code>.
1670 </p>
1671 </dd>
1672 <dt class="hdlist1">
1673 -B[&lt;n&gt;][/&lt;m&gt;]
1674 </dt>
1675 <dt class="hdlist1">
1676 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1677 </dt>
1678 <dd>
1680 Break complete rewrite changes into pairs of delete and
1681 create. This serves two purposes:
1682 </p>
1683 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1684 not as a series of deletion and insertion mixed together with a very
1685 few lines that happen to match textually as the context, but as a
1686 single deletion of everything old followed by a single insertion of
1687 everything new, and the number <code>m</code> controls this aspect of the -B
1688 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1689 original should remain in the result for Git to consider it a total
1690 rewrite (i.e. otherwise the resulting patch will be a series of
1691 deletion and insertion mixed together with context lines).</p></div>
1692 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1693 source of a rename (usually -M only considers a file that disappeared
1694 as the source of a rename), and the number <code>n</code> controls this aspect of
1695 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1696 addition and deletion compared to 20% or more of the file&#8217;s size are
1697 eligible for being picked up as a possible source of a rename to
1698 another file.</p></div>
1699 </dd>
1700 <dt class="hdlist1">
1701 -M[&lt;n&gt;]
1702 </dt>
1703 <dt class="hdlist1">
1704 --find-renames[=&lt;n&gt;]
1705 </dt>
1706 <dd>
1708 Detect renames.
1709 If <code>n</code> is specified, it is a threshold on the similarity
1710 index (i.e. amount of addition/deletions compared to the
1711 file&#8217;s size). For example, <code>-M90%</code> means Git should consider a
1712 delete/add pair to be a rename if more than 90% of the file
1713 hasn&#8217;t changed. Without a <code>%</code> sign, the number is to be read as
1714 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1715 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1716 the same as <code>-M5%</code>. To limit detection to exact renames, use
1717 <code>-M100%</code>. The default similarity index is 50%.
1718 </p>
1719 </dd>
1720 <dt class="hdlist1">
1721 -C[&lt;n&gt;]
1722 </dt>
1723 <dt class="hdlist1">
1724 --find-copies[=&lt;n&gt;]
1725 </dt>
1726 <dd>
1728 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1729 If <code>n</code> is specified, it has the same meaning as for <code>-M&lt;n&gt;</code>.
1730 </p>
1731 </dd>
1732 <dt class="hdlist1">
1733 --find-copies-harder
1734 </dt>
1735 <dd>
1737 For performance reasons, by default, <code>-C</code> option finds copies only
1738 if the original file of the copy was modified in the same
1739 changeset. This flag makes the command
1740 inspect unmodified files as candidates for the source of
1741 copy. This is a very expensive operation for large
1742 projects, so use it with caution. Giving more than one
1743 <code>-C</code> option has the same effect.
1744 </p>
1745 </dd>
1746 <dt class="hdlist1">
1748 </dt>
1749 <dt class="hdlist1">
1750 --irreversible-delete
1751 </dt>
1752 <dd>
1754 Omit the preimage for deletes, i.e. print only the header but not
1755 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1756 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1757 solely for people who want to just concentrate on reviewing the
1758 text after the change. In addition, the output obviously lacks
1759 enough information to apply such a patch in reverse, even manually,
1760 hence the name of the option.
1761 </p>
1762 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1763 of a delete/create pair.</p></div>
1764 </dd>
1765 <dt class="hdlist1">
1766 -l&lt;num&gt;
1767 </dt>
1768 <dd>
1770 The <code>-M</code> and <code>-C</code> options involve some preliminary steps that
1771 can detect subsets of renames/copies cheaply, followed by an
1772 exhaustive fallback portion that compares all remaining
1773 unpaired destinations to all relevant sources. (For renames,
1774 only remaining unpaired sources are relevant; for copies, all
1775 original sources are relevant.) For N sources and
1776 destinations, this exhaustive check is O(N^2). This option
1777 prevents the exhaustive portion of rename/copy detection from
1778 running if the number of source/destination files involved
1779 exceeds the specified number. Defaults to diff.renameLimit.
1780 Note that a value of 0 is treated as unlimited.
1781 </p>
1782 </dd>
1783 <dt class="hdlist1">
1784 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1785 </dt>
1786 <dd>
1788 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1789 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1790 type (i.e. regular file, symlink, submodule, &#8230;) changed (<code>T</code>),
1791 are Unmerged (<code>U</code>), are
1792 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1793 Any combination of the filter characters (including none) can be used.
1794 When <code>*</code> (All-or-none) is added to the combination, all
1795 paths are selected if there is any file that matches
1796 other criteria in the comparison; if there is no file
1797 that matches other criteria, nothing is selected.
1798 </p>
1799 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1800 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1801 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1802 renamed entries cannot appear if detection for those types is disabled.</p></div>
1803 </dd>
1804 <dt class="hdlist1">
1805 -S&lt;string&gt;
1806 </dt>
1807 <dd>
1809 Look for differences that change the number of occurrences of
1810 the specified string (i.e. addition/deletion) in a file.
1811 Intended for the scripter&#8217;s use.
1812 </p>
1813 <div class="paragraph"><p>It is useful when you&#8217;re looking for an exact block of code (like a
1814 struct), and want to know the history of that block since it first
1815 came into being: use the feature iteratively to feed the interesting
1816 block in the preimage back into <code>-S</code>, and keep going until you get the
1817 very first version of the block.</p></div>
1818 <div class="paragraph"><p>Binary files are searched as well.</p></div>
1819 </dd>
1820 <dt class="hdlist1">
1821 -G&lt;regex&gt;
1822 </dt>
1823 <dd>
1825 Look for differences whose patch text contains added/removed
1826 lines that match &lt;regex&gt;.
1827 </p>
1828 <div class="paragraph"><p>To illustrate the difference between <code>-S&lt;regex&gt; --pickaxe-regex</code> and
1829 <code>-G&lt;regex&gt;</code>, consider a commit with the following diff in the same
1830 file:</p></div>
1831 <div class="listingblock">
1832 <div class="content">
1833 <pre><code>+ return frotz(nitfol, two-&gt;ptr, 1, 0);
1835 - hit = frotz(nitfol, mf2.ptr, 1, 0);</code></pre>
1836 </div></div>
1837 <div class="paragraph"><p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log
1838 -S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of
1839 occurrences of that string did not change).</p></div>
1840 <div class="paragraph"><p>Unless <code>--text</code> is supplied patches of binary files without a textconv
1841 filter will be ignored.</p></div>
1842 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1843 information.</p></div>
1844 </dd>
1845 <dt class="hdlist1">
1846 --find-object=&lt;object-id&gt;
1847 </dt>
1848 <dd>
1850 Look for differences that change the number of occurrences of
1851 the specified object. Similar to <code>-S</code>, just the argument is different
1852 in that it doesn&#8217;t search for a specific string but for a specific
1853 object id.
1854 </p>
1855 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1856 <code>git-log</code> to also find trees.</p></div>
1857 </dd>
1858 <dt class="hdlist1">
1859 --pickaxe-all
1860 </dt>
1861 <dd>
1863 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1864 changeset, not just the files that contain the change
1865 in &lt;string&gt;.
1866 </p>
1867 </dd>
1868 <dt class="hdlist1">
1869 --pickaxe-regex
1870 </dt>
1871 <dd>
1873 Treat the &lt;string&gt; given to <code>-S</code> as an extended POSIX regular
1874 expression to match.
1875 </p>
1876 </dd>
1877 <dt class="hdlist1">
1878 -O&lt;orderfile&gt;
1879 </dt>
1880 <dd>
1882 Control the order in which files appear in the output.
1883 This overrides the <code>diff.orderFile</code> configuration variable
1884 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1885 use <code>-O/dev/null</code>.
1886 </p>
1887 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1888 &lt;orderfile&gt;.
1889 All files with pathnames that match the first pattern are output
1890 first, all files with pathnames that match the second pattern (but not
1891 the first) are output next, and so on.
1892 All files with pathnames that do not match any pattern are output
1893 last, as if there was an implicit match-all pattern at the end of the
1894 file.
1895 If multiple pathnames have the same rank (they match the same pattern
1896 but no earlier patterns), their output order relative to each other is
1897 the normal order.</p></div>
1898 <div class="paragraph"><p>&lt;orderfile&gt; is parsed as follows:</p></div>
1899 <div class="openblock">
1900 <div class="content">
1901 <div class="ulist"><ul>
1902 <li>
1904 Blank lines are ignored, so they can be used as separators for
1905 readability.
1906 </p>
1907 </li>
1908 <li>
1910 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1911 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1912 pattern if it starts with a hash.
1913 </p>
1914 </li>
1915 <li>
1917 Each other line contains a single pattern.
1918 </p>
1919 </li>
1920 </ul></div>
1921 </div></div>
1922 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1923 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1924 matches a pattern if removing any number of the final pathname
1925 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1926 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1927 </dd>
1928 <dt class="hdlist1">
1929 --skip-to=&lt;file&gt;
1930 </dt>
1931 <dt class="hdlist1">
1932 --rotate-to=&lt;file&gt;
1933 </dt>
1934 <dd>
1936 Discard the files before the named &lt;file&gt; from the output
1937 (i.e. <em>skip to</em>), or move them to the end of the output
1938 (i.e. <em>rotate to</em>). These options were invented primarily for the use
1939 of the <code>git difftool</code> command, and may not be very useful
1940 otherwise.
1941 </p>
1942 </dd>
1943 <dt class="hdlist1">
1945 </dt>
1946 <dd>
1948 Swap two inputs; that is, show differences from index or
1949 on-disk file to tree contents.
1950 </p>
1951 </dd>
1952 <dt class="hdlist1">
1953 --relative[=&lt;path&gt;]
1954 </dt>
1955 <dt class="hdlist1">
1956 --no-relative
1957 </dt>
1958 <dd>
1960 When run from a subdirectory of the project, it can be
1961 told to exclude changes outside the directory and show
1962 pathnames relative to it with this option. When you are
1963 not in a subdirectory (e.g. in a bare repository), you
1964 can name which subdirectory to make the output relative
1965 to by giving a &lt;path&gt; as an argument.
1966 <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config
1967 option and previous <code>--relative</code>.
1968 </p>
1969 </dd>
1970 <dt class="hdlist1">
1972 </dt>
1973 <dt class="hdlist1">
1974 --text
1975 </dt>
1976 <dd>
1978 Treat all files as text.
1979 </p>
1980 </dd>
1981 <dt class="hdlist1">
1982 --ignore-cr-at-eol
1983 </dt>
1984 <dd>
1986 Ignore carriage-return at the end of line when doing a comparison.
1987 </p>
1988 </dd>
1989 <dt class="hdlist1">
1990 --ignore-space-at-eol
1991 </dt>
1992 <dd>
1994 Ignore changes in whitespace at EOL.
1995 </p>
1996 </dd>
1997 <dt class="hdlist1">
1999 </dt>
2000 <dt class="hdlist1">
2001 --ignore-space-change
2002 </dt>
2003 <dd>
2005 Ignore changes in amount of whitespace. This ignores whitespace
2006 at line end, and considers all other sequences of one or
2007 more whitespace characters to be equivalent.
2008 </p>
2009 </dd>
2010 <dt class="hdlist1">
2012 </dt>
2013 <dt class="hdlist1">
2014 --ignore-all-space
2015 </dt>
2016 <dd>
2018 Ignore whitespace when comparing lines. This ignores
2019 differences even if one line has whitespace where the other
2020 line has none.
2021 </p>
2022 </dd>
2023 <dt class="hdlist1">
2024 --ignore-blank-lines
2025 </dt>
2026 <dd>
2028 Ignore changes whose lines are all blank.
2029 </p>
2030 </dd>
2031 <dt class="hdlist1">
2032 -I&lt;regex&gt;
2033 </dt>
2034 <dt class="hdlist1">
2035 --ignore-matching-lines=&lt;regex&gt;
2036 </dt>
2037 <dd>
2039 Ignore changes whose all lines match &lt;regex&gt;. This option may
2040 be specified more than once.
2041 </p>
2042 </dd>
2043 <dt class="hdlist1">
2044 --inter-hunk-context=&lt;lines&gt;
2045 </dt>
2046 <dd>
2048 Show the context between diff hunks, up to the specified number
2049 of lines, thereby fusing hunks that are close to each other.
2050 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
2051 is unset.
2052 </p>
2053 </dd>
2054 <dt class="hdlist1">
2056 </dt>
2057 <dt class="hdlist1">
2058 --function-context
2059 </dt>
2060 <dd>
2062 Show whole function as context lines for each change.
2063 The function names are determined in the same way as
2064 <code>git diff</code> works out patch hunk headers (see <em>Defining a
2065 custom hunk-header</em> in <a href="gitattributes.html">gitattributes(5)</a>).
2066 </p>
2067 </dd>
2068 <dt class="hdlist1">
2069 --exit-code
2070 </dt>
2071 <dd>
2073 Make the program exit with codes similar to diff(1).
2074 That is, it exits with 1 if there were differences and
2075 0 means no differences.
2076 </p>
2077 </dd>
2078 <dt class="hdlist1">
2079 --quiet
2080 </dt>
2081 <dd>
2083 Disable all output of the program. Implies <code>--exit-code</code>.
2084 </p>
2085 </dd>
2086 <dt class="hdlist1">
2087 --ext-diff
2088 </dt>
2089 <dd>
2091 Allow an external diff helper to be executed. If you set an
2092 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
2093 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
2094 </p>
2095 </dd>
2096 <dt class="hdlist1">
2097 --no-ext-diff
2098 </dt>
2099 <dd>
2101 Disallow external diff drivers.
2102 </p>
2103 </dd>
2104 <dt class="hdlist1">
2105 --textconv
2106 </dt>
2107 <dt class="hdlist1">
2108 --no-textconv
2109 </dt>
2110 <dd>
2112 Allow (or disallow) external text conversion filters to be run
2113 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
2114 details. Because textconv filters are typically a one-way
2115 conversion, the resulting diff is suitable for human
2116 consumption, but cannot be applied. For this reason, textconv
2117 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
2118 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
2119 diff plumbing commands.
2120 </p>
2121 </dd>
2122 <dt class="hdlist1">
2123 --ignore-submodules[=&lt;when&gt;]
2124 </dt>
2125 <dd>
2127 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
2128 either "none", "untracked", "dirty" or "all", which is the default.
2129 Using "none" will consider the submodule modified when it either contains
2130 untracked or modified files or its HEAD differs from the commit recorded
2131 in the superproject and can be used to override any settings of the
2132 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
2133 "untracked" is used submodules are not considered dirty when they only
2134 contain untracked content (but they are still scanned for modified
2135 content). Using "dirty" ignores all changes to the work tree of submodules,
2136 only changes to the commits stored in the superproject are shown (this was
2137 the behavior until 1.7.0). Using "all" hides all changes to submodules.
2138 </p>
2139 </dd>
2140 <dt class="hdlist1">
2141 --src-prefix=&lt;prefix&gt;
2142 </dt>
2143 <dd>
2145 Show the given source prefix instead of "a/".
2146 </p>
2147 </dd>
2148 <dt class="hdlist1">
2149 --dst-prefix=&lt;prefix&gt;
2150 </dt>
2151 <dd>
2153 Show the given destination prefix instead of "b/".
2154 </p>
2155 </dd>
2156 <dt class="hdlist1">
2157 --no-prefix
2158 </dt>
2159 <dd>
2161 Do not show any source or destination prefix.
2162 </p>
2163 </dd>
2164 <dt class="hdlist1">
2165 --default-prefix
2166 </dt>
2167 <dd>
2169 Use the default source and destination prefixes ("a/" and "b/").
2170 This overrides configuration variables such as <code>diff.noprefix</code>,
2171 <code>diff.srcPrefix</code>, <code>diff.dstPrefix</code>, and <code>diff.mnemonicPrefix</code>
2172 (see <code>git-config</code>(1)).
2173 </p>
2174 </dd>
2175 <dt class="hdlist1">
2176 --line-prefix=&lt;prefix&gt;
2177 </dt>
2178 <dd>
2180 Prepend an additional prefix to every line of output.
2181 </p>
2182 </dd>
2183 <dt class="hdlist1">
2184 --ita-invisible-in-index
2185 </dt>
2186 <dd>
2188 By default entries added by "git add -N" appear as an existing
2189 empty file in "git diff" and a new file in "git diff --cached".
2190 This option makes the entry appear as a new file in "git diff"
2191 and non-existent in "git diff --cached". This option could be
2192 reverted with <code>--ita-visible-in-index</code>. Both options are
2193 experimental and could be removed in future.
2194 </p>
2195 </dd>
2196 </dl></div>
2197 <div class="paragraph"><p>For more detailed explanation on these common options, see also
2198 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
2199 <div class="dlist"><dl>
2200 <dt class="hdlist1">
2201 -1 --base
2202 </dt>
2203 <dt class="hdlist1">
2204 -2 --ours
2205 </dt>
2206 <dt class="hdlist1">
2207 -3 --theirs
2208 </dt>
2209 <dd>
2211 Compare the working tree with the "base" version (stage #1),
2212 "our branch" (stage #2) or "their branch" (stage #3). The
2213 index contains these stages only for unmerged entries i.e.
2214 while resolving conflicts. See <a href="git-read-tree.html">git-read-tree(1)</a>
2215 section "3-Way Merge" for detailed information.
2216 </p>
2217 </dd>
2218 <dt class="hdlist1">
2220 </dt>
2221 <dd>
2223 Omit diff output for unmerged entries and just show
2224 "Unmerged". Can be used only when comparing the working tree
2225 with the index.
2226 </p>
2227 </dd>
2228 <dt class="hdlist1">
2229 &lt;path&gt;&#8230;
2230 </dt>
2231 <dd>
2233 The &lt;paths&gt; parameters, when given, are used to limit
2234 the diff to the named paths (you can give directory
2235 names and get diff for all files under them).
2236 </p>
2237 </dd>
2238 </dl></div>
2239 </div>
2240 </div>
2241 <div class="sect1">
2242 <h2 id="_raw_output_format">Raw output format</h2>
2243 <div class="sectionbody">
2244 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
2245 "git-diff-files" and "git diff --raw" are very similar.</p></div>
2246 <div class="paragraph"><p>These commands all compare two sets of things; what is
2247 compared differs:</p></div>
2248 <div class="dlist"><dl>
2249 <dt class="hdlist1">
2250 git-diff-index &lt;tree-ish&gt;
2251 </dt>
2252 <dd>
2254 compares the &lt;tree-ish&gt; and the files on the filesystem.
2255 </p>
2256 </dd>
2257 <dt class="hdlist1">
2258 git-diff-index --cached &lt;tree-ish&gt;
2259 </dt>
2260 <dd>
2262 compares the &lt;tree-ish&gt; and the index.
2263 </p>
2264 </dd>
2265 <dt class="hdlist1">
2266 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
2267 </dt>
2268 <dd>
2270 compares the trees named by the two arguments.
2271 </p>
2272 </dd>
2273 <dt class="hdlist1">
2274 git-diff-files [&lt;pattern&gt;&#8230;]
2275 </dt>
2276 <dd>
2278 compares the index and the files on the filesystem.
2279 </p>
2280 </dd>
2281 </dl></div>
2282 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
2283 what is being compared. After that, all the commands print one output
2284 line per changed file.</p></div>
2285 <div class="paragraph"><p>An output line is formatted this way:</p></div>
2286 <div class="listingblock">
2287 <div class="content">
2288 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
2289 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
2290 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
2291 create :000000 100644 0000000 1234567 A file4
2292 delete :100644 000000 1234567 0000000 D file5
2293 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2294 </div></div>
2295 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2296 <div class="olist arabic"><ol class="arabic">
2297 <li>
2299 a colon.
2300 </p>
2301 </li>
2302 <li>
2304 mode for "src"; 000000 if creation or unmerged.
2305 </p>
2306 </li>
2307 <li>
2309 a space.
2310 </p>
2311 </li>
2312 <li>
2314 mode for "dst"; 000000 if deletion or unmerged.
2315 </p>
2316 </li>
2317 <li>
2319 a space.
2320 </p>
2321 </li>
2322 <li>
2324 sha1 for "src"; 0{40} if creation or unmerged.
2325 </p>
2326 </li>
2327 <li>
2329 a space.
2330 </p>
2331 </li>
2332 <li>
2334 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".
2335 </p>
2336 </li>
2337 <li>
2339 a space.
2340 </p>
2341 </li>
2342 <li>
2344 status, followed by optional "score" number.
2345 </p>
2346 </li>
2347 <li>
2349 a tab or a NUL when <code>-z</code> option is used.
2350 </p>
2351 </li>
2352 <li>
2354 path for "src"
2355 </p>
2356 </li>
2357 <li>
2359 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2360 </p>
2361 </li>
2362 <li>
2364 path for "dst"; only exists for C or R.
2365 </p>
2366 </li>
2367 <li>
2369 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2370 </p>
2371 </li>
2372 </ol></div>
2373 <div class="paragraph"><p>Possible status letters are:</p></div>
2374 <div class="ulist"><ul>
2375 <li>
2377 A: addition of a file
2378 </p>
2379 </li>
2380 <li>
2382 C: copy of a file into a new one
2383 </p>
2384 </li>
2385 <li>
2387 D: deletion of a file
2388 </p>
2389 </li>
2390 <li>
2392 M: modification of the contents or mode of a file
2393 </p>
2394 </li>
2395 <li>
2397 R: renaming of a file
2398 </p>
2399 </li>
2400 <li>
2402 T: change in the type of the file (regular file, symbolic link or submodule)
2403 </p>
2404 </li>
2405 <li>
2407 U: file is unmerged (you must complete the merge before it can
2408 be committed)
2409 </p>
2410 </li>
2411 <li>
2413 X: "unknown" change type (most probably a bug, please report it)
2414 </p>
2415 </li>
2416 </ul></div>
2417 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2418 percentage of similarity between the source and target of the move or
2419 copy). Status letter M may be followed by a score (denoting the
2420 percentage of dissimilarity) for file rewrites.</p></div>
2421 <div class="paragraph"><p>The sha1 for "dst" is shown as all 0&#8217;s if a file on the filesystem
2422 is out of sync with the index.</p></div>
2423 <div class="paragraph"><p>Example:</p></div>
2424 <div class="listingblock">
2425 <div class="content">
2426 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2427 </div></div>
2428 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2429 quoted as explained for the configuration variable <code>core.quotePath</code>
2430 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2431 verbatim and the line is terminated by a NUL byte.</p></div>
2432 </div>
2433 </div>
2434 <div class="sect1">
2435 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2436 <div class="sectionbody">
2437 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2438 can take <code>-c</code> or <code>--cc</code> option
2439 to generate diff output also for merge commits. The output differs
2440 from the format described above in the following way:</p></div>
2441 <div class="olist arabic"><ol class="arabic">
2442 <li>
2444 there is a colon for each parent
2445 </p>
2446 </li>
2447 <li>
2449 there are more "src" modes and "src" sha1
2450 </p>
2451 </li>
2452 <li>
2454 status is concatenated status characters for each parent
2455 </p>
2456 </li>
2457 <li>
2459 no optional "score" number
2460 </p>
2461 </li>
2462 <li>
2464 tab-separated pathname(s) of the file
2465 </p>
2466 </li>
2467 </ol></div>
2468 <div class="paragraph"><p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even
2469 if the file was renamed on any side of history. With
2470 <code>--combined-all-paths</code>, the name of the path in each parent is shown
2471 followed by the name of the path in the merge commit.</p></div>
2472 <div class="paragraph"><p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p></div>
2473 <div class="listingblock">
2474 <div class="content">
2475 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
2476 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
2477 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</code></pre>
2478 </div></div>
2479 <div class="paragraph"><p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p></div>
2480 <div class="listingblock">
2481 <div class="content">
2482 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
2483 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2484 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</code></pre>
2485 </div></div>
2486 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2487 all parents.</p></div>
2488 </div>
2489 </div>
2490 <div class="sect1">
2491 <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2>
2492 <div class="sectionbody">
2493 <div class="paragraph"><p>Running
2494 <a href="git-diff.html">git-diff(1)</a>,
2495 <a href="git-log.html">git-log(1)</a>,
2496 <a href="git-show.html">git-show(1)</a>,
2497 <a href="git-diff-index.html">git-diff-index(1)</a>,
2498 <a href="git-diff-tree.html">git-diff-tree(1)</a>, or
2499 <a href="git-diff-files.html">git-diff-files(1)</a>
2500 with the <code>-p</code> option produces patch text.
2501 You can customize the creation of patch text via the
2502 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables
2503 (see <a href="git.html">git(1)</a>), and the <code>diff</code> attribute (see <a href="gitattributes.html">gitattributes(5)</a>).</p></div>
2504 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2505 diff format:</p></div>
2506 <div class="olist arabic"><ol class="arabic">
2507 <li>
2509 It is preceded by a "git diff" header that looks like this:
2510 </p>
2511 <div class="literalblock">
2512 <div class="content">
2513 <pre><code>diff --git a/file1 b/file2</code></pre>
2514 </div></div>
2515 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2516 involved. Especially, even for a creation or a deletion,
2517 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2518 <div class="paragraph"><p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2519 name of the source file of the rename/copy and the name of
2520 the file that the rename/copy produces, respectively.</p></div>
2521 </li>
2522 <li>
2524 It is followed by one or more extended header lines:
2525 </p>
2526 <div class="literalblock">
2527 <div class="content">
2528 <pre><code>old mode &lt;mode&gt;
2529 new mode &lt;mode&gt;
2530 deleted file mode &lt;mode&gt;
2531 new file mode &lt;mode&gt;
2532 copy from &lt;path&gt;
2533 copy to &lt;path&gt;
2534 rename from &lt;path&gt;
2535 rename to &lt;path&gt;
2536 similarity index &lt;number&gt;
2537 dissimilarity index &lt;number&gt;
2538 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</code></pre>
2539 </div></div>
2540 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2541 and file permission bits.</p></div>
2542 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2543 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2544 the dissimilarity index is the percentage of changed lines. It
2545 is a rounded down integer, followed by a percent sign. The
2546 similarity index value of 100% is thus reserved for two equal
2547 files, while 100% dissimilarity means that no line from the old
2548 file made it into the new one.</p></div>
2549 <div class="paragraph"><p>The index line includes the blob object names before and after the change.
2550 The &lt;mode&gt; is included if the file mode does not change; otherwise,
2551 separate lines indicate the old and the new mode.</p></div>
2552 </li>
2553 <li>
2555 Pathnames with "unusual" characters are quoted as explained for
2556 the configuration variable <code>core.quotePath</code> (see
2557 <a href="git-config.html">git-config(1)</a>).
2558 </p>
2559 </li>
2560 <li>
2562 All the <code>file1</code> files in the output refer to files before the
2563 commit, and all the <code>file2</code> files refer to files after the commit.
2564 It is incorrect to apply each change to each file sequentially. For
2565 example, this patch will swap a and b:
2566 </p>
2567 <div class="literalblock">
2568 <div class="content">
2569 <pre><code>diff --git a/a b/b
2570 rename from a
2571 rename to b
2572 diff --git a/b b/a
2573 rename from b
2574 rename to a</code></pre>
2575 </div></div>
2576 </li>
2577 <li>
2579 Hunk headers mention the name of the function to which the hunk
2580 applies. See "Defining a custom hunk-header" in
2581 <a href="gitattributes.html">gitattributes(5)</a> for details of how to tailor this to
2582 specific languages.
2583 </p>
2584 </li>
2585 </ol></div>
2586 </div>
2587 </div>
2588 <div class="sect1">
2589 <h2 id="_combined_diff_format">Combined diff format</h2>
2590 <div class="sectionbody">
2591 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2592 produce a <em>combined diff</em> when showing a merge. This is the default
2593 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2594 <a href="git-show.html">git-show(1)</a>. Note also that you can give suitable
2595 <code>--diff-merges</code> option to any of these commands to force generation of
2596 diffs in a specific format.</p></div>
2597 <div class="paragraph"><p>A "combined diff" format looks like this:</p></div>
2598 <div class="listingblock">
2599 <div class="content">
2600 <pre><code>diff --combined describe.c
2601 index fabadb8,cc95eb0..4866510
2602 --- a/describe.c
2603 +++ b/describe.c
2604 @@@ -98,20 -98,12 +98,20 @@@
2605 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2608 - static void describe(char *arg)
2609 -static void describe(struct commit *cmit, int last_one)
2610 ++static void describe(char *arg, int last_one)
2612 + unsigned char sha1[20];
2613 + struct commit *cmit;
2614 struct commit_list *list;
2615 static int initialized = 0;
2616 struct commit_name *n;
2618 + if (get_sha1(arg, sha1) &lt; 0)
2619 + usage(describe_usage);
2620 + cmit = lookup_commit_reference(sha1);
2621 + if (!cmit)
2622 + usage(describe_usage);
2624 if (!initialized) {
2625 initialized = 1;
2626 for_each_ref(get_name);</code></pre>
2627 </div></div>
2628 <div class="olist arabic"><ol class="arabic">
2629 <li>
2631 It is preceded by a "git diff" header, that looks like
2632 this (when the <code>-c</code> option is used):
2633 </p>
2634 <div class="literalblock">
2635 <div class="content">
2636 <pre><code>diff --combined file</code></pre>
2637 </div></div>
2638 <div class="paragraph"><p>or like this (when the <code>--cc</code> option is used):</p></div>
2639 <div class="literalblock">
2640 <div class="content">
2641 <pre><code>diff --cc file</code></pre>
2642 </div></div>
2643 </li>
2644 <li>
2646 It is followed by one or more extended header lines
2647 (this example shows a merge with two parents):
2648 </p>
2649 <div class="literalblock">
2650 <div class="content">
2651 <pre><code>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
2652 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
2653 new file mode &lt;mode&gt;
2654 deleted file mode &lt;mode&gt;,&lt;mode&gt;</code></pre>
2655 </div></div>
2656 <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
2657 the &lt;mode&gt; is different from the rest. Extended headers with
2658 information about detected content movement (renames and
2659 copying detection) are designed to work with the diff of two
2660 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
2661 </li>
2662 <li>
2664 It is followed by a two-line from-file/to-file header:
2665 </p>
2666 <div class="literalblock">
2667 <div class="content">
2668 <pre><code>--- a/file
2669 +++ b/file</code></pre>
2670 </div></div>
2671 <div class="paragraph"><p>Similar to the two-line header for the traditional <em>unified</em> diff
2672 format, <code>/dev/null</code> is used to signal created or deleted
2673 files.</p></div>
2674 <div class="paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2675 two-line from-file/to-file, you get an N+1 line from-file/to-file header,
2676 where N is the number of parents in the merge commit:</p></div>
2677 <div class="literalblock">
2678 <div class="content">
2679 <pre><code>--- a/file
2680 --- a/file
2681 --- a/file
2682 +++ b/file</code></pre>
2683 </div></div>
2684 <div class="paragraph"><p>This extended format can be useful if rename or copy detection is
2685 active, to allow you to see the original name of the file in different
2686 parents.</p></div>
2687 </li>
2688 <li>
2690 Chunk header format is modified to prevent people from
2691 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2692 was created for review of merge commit changes, and was not
2693 meant to be applied. The change is similar to the change in the
2694 extended <em>index</em> header:
2695 </p>
2696 <div class="literalblock">
2697 <div class="content">
2698 <pre><code>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</code></pre>
2699 </div></div>
2700 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2701 header for combined diff format.</p></div>
2702 </li>
2703 </ol></div>
2704 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2705 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
2706 added to B), or <code>" "</code> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
2707 compares two or more files file1, file2,&#8230; with one file X, and
2708 shows how X differs from each of fileN. One column for each of
2709 fileN is prepended to the output line to note how X&#8217;s line is
2710 different from it.</p></div>
2711 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2712 fileN but it does not appear in the result. A <code>+</code> character
2713 in the column N means that the line appears in the result,
2714 and fileN does not have that line (in other words, the line was
2715 added, from the point of view of that parent).</p></div>
2716 <div class="paragraph"><p>In the above example output, the function signature was changed
2717 from both files (hence two <code>-</code> removals from both file1 and
2718 file2, plus <code>++</code> to mean one line that was added does not appear
2719 in either file1 or file2). Also, eight other lines are the same
2720 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2721 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2722 merge commit with the merge result (i.e. file1..fileN are the
2723 parents). When shown by <code>git diff-files -c</code>, it compares the
2724 two unresolved merge parents with the working tree file
2725 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2726 "their version").</p></div>
2727 </div>
2728 </div>
2729 <div class="sect1">
2730 <h2 id="_other_diff_formats">other diff formats</h2>
2731 <div class="sectionbody">
2732 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2733 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2734 output. These options can be combined with other options, such as
2735 <code>-p</code>, and are meant for human consumption.</p></div>
2736 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2737 formats the pathnames compactly by combining common prefix and suffix of
2738 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2739 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2740 <div class="listingblock">
2741 <div class="content">
2742 <pre><code>arch/{i386 =&gt; x86}/Makefile | 4 +--</code></pre>
2743 </div></div>
2744 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2745 for easier machine consumption. An entry in <code>--numstat</code> output looks
2746 like this:</p></div>
2747 <div class="listingblock">
2748 <div class="content">
2749 <pre><code>1 2 README
2750 3 1 arch/{i386 =&gt; x86}/Makefile</code></pre>
2751 </div></div>
2752 <div class="paragraph"><p>That is, from left to right:</p></div>
2753 <div class="olist arabic"><ol class="arabic">
2754 <li>
2756 the number of added lines;
2757 </p>
2758 </li>
2759 <li>
2761 a tab;
2762 </p>
2763 </li>
2764 <li>
2766 the number of deleted lines;
2767 </p>
2768 </li>
2769 <li>
2771 a tab;
2772 </p>
2773 </li>
2774 <li>
2776 pathname (possibly with rename/copy information);
2777 </p>
2778 </li>
2779 <li>
2781 a newline.
2782 </p>
2783 </li>
2784 </ol></div>
2785 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2786 <div class="listingblock">
2787 <div class="content">
2788 <pre><code>1 2 README NUL
2789 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2790 </div></div>
2791 <div class="paragraph"><p>That is:</p></div>
2792 <div class="olist arabic"><ol class="arabic">
2793 <li>
2795 the number of added lines;
2796 </p>
2797 </li>
2798 <li>
2800 a tab;
2801 </p>
2802 </li>
2803 <li>
2805 the number of deleted lines;
2806 </p>
2807 </li>
2808 <li>
2810 a tab;
2811 </p>
2812 </li>
2813 <li>
2815 a NUL (only exists if renamed/copied);
2816 </p>
2817 </li>
2818 <li>
2820 pathname in preimage;
2821 </p>
2822 </li>
2823 <li>
2825 a NUL (only exists if renamed/copied);
2826 </p>
2827 </li>
2828 <li>
2830 pathname in postimage (only exists if renamed/copied);
2831 </p>
2832 </li>
2833 <li>
2835 a NUL.
2836 </p>
2837 </li>
2838 </ol></div>
2839 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2840 scripts that read the output to tell if the current record being read is
2841 a single-path record or a rename/copy record without reading ahead.
2842 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2843 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2844 </div>
2845 </div>
2846 <div class="sect1">
2847 <h2 id="_examples">EXAMPLES</h2>
2848 <div class="sectionbody">
2849 <div class="dlist"><dl>
2850 <dt class="hdlist1">
2851 Various ways to check your working tree
2852 </dt>
2853 <dd>
2854 <div class="listingblock">
2855 <div class="content">
2856 <pre><code>$ git diff <b>&lt;1&gt;</b>
2857 $ git diff --cached <b>&lt;2&gt;</b>
2858 $ git diff HEAD <b>&lt;3&gt;</b>
2859 $ git diff AUTO_MERGE <b>&lt;4&gt;</b></code></pre>
2860 </div></div>
2861 <div class="colist arabic"><ol>
2862 <li>
2864 Changes in the working tree not yet staged for the next commit.
2865 </p>
2866 </li>
2867 <li>
2869 Changes between the index and your last commit; what you
2870 would be committing if you run <code>git commit</code> without <code>-a</code> option.
2871 </p>
2872 </li>
2873 <li>
2875 Changes in the working tree since your last commit; what you
2876 would be committing if you run <code>git commit -a</code>
2877 </p>
2878 </li>
2879 <li>
2881 Changes in the working tree you&#8217;ve made to resolve textual
2882 conflicts so far.
2883 </p>
2884 </li>
2885 </ol></div>
2886 </dd>
2887 <dt class="hdlist1">
2888 Comparing with arbitrary commits
2889 </dt>
2890 <dd>
2891 <div class="listingblock">
2892 <div class="content">
2893 <pre><code>$ git diff test <b>&lt;1&gt;</b>
2894 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
2895 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></code></pre>
2896 </div></div>
2897 <div class="colist arabic"><ol>
2898 <li>
2900 Instead of using the tip of the current branch, compare with the
2901 tip of "test" branch.
2902 </p>
2903 </li>
2904 <li>
2906 Instead of comparing with the tip of "test" branch, compare with
2907 the tip of the current branch, but limit the comparison to the
2908 file "test".
2909 </p>
2910 </li>
2911 <li>
2913 Compare the version before the last commit and the last commit.
2914 </p>
2915 </li>
2916 </ol></div>
2917 </dd>
2918 <dt class="hdlist1">
2919 Comparing branches
2920 </dt>
2921 <dd>
2922 <div class="listingblock">
2923 <div class="content">
2924 <pre><code>$ git diff topic master <b>&lt;1&gt;</b>
2925 $ git diff topic..master <b>&lt;2&gt;</b>
2926 $ git diff topic...master <b>&lt;3&gt;</b></code></pre>
2927 </div></div>
2928 <div class="colist arabic"><ol>
2929 <li>
2931 Changes between the tips of the topic and the master branches.
2932 </p>
2933 </li>
2934 <li>
2936 Same as above.
2937 </p>
2938 </li>
2939 <li>
2941 Changes that occurred on the master branch since when the topic
2942 branch was started off it.
2943 </p>
2944 </li>
2945 </ol></div>
2946 </dd>
2947 <dt class="hdlist1">
2948 Limiting the diff output
2949 </dt>
2950 <dd>
2951 <div class="listingblock">
2952 <div class="content">
2953 <pre><code>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
2954 $ git diff --name-status <b>&lt;2&gt;</b>
2955 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></code></pre>
2956 </div></div>
2957 <div class="colist arabic"><ol>
2958 <li>
2960 Show only modification, rename, and copy, but not addition
2961 or deletion.
2962 </p>
2963 </li>
2964 <li>
2966 Show only names and the nature of change, but not actual
2967 diff output.
2968 </p>
2969 </li>
2970 <li>
2972 Limit diff output to named subtrees.
2973 </p>
2974 </li>
2975 </ol></div>
2976 </dd>
2977 <dt class="hdlist1">
2978 Munging the diff output
2979 </dt>
2980 <dd>
2981 <div class="listingblock">
2982 <div class="content">
2983 <pre><code>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
2984 $ git diff -R <b>&lt;2&gt;</b></code></pre>
2985 </div></div>
2986 <div class="colist arabic"><ol>
2987 <li>
2989 Spend extra cycles to find renames, copies and complete
2990 rewrites (very expensive).
2991 </p>
2992 </li>
2993 <li>
2995 Output diff in reverse.
2996 </p>
2997 </li>
2998 </ol></div>
2999 </dd>
3000 </dl></div>
3001 </div>
3002 </div>
3003 <div class="sect1">
3004 <h2 id="_configuration">CONFIGURATION</h2>
3005 <div class="sectionbody">
3006 <div class="paragraph"><p>Everything below this line in this section is selectively included
3007 from the <a href="git-config.html">git-config(1)</a> documentation. The content is the same
3008 as what&#8217;s found there:</p></div>
3009 <div class="dlist"><dl>
3010 <dt class="hdlist1">
3011 diff.autoRefreshIndex
3012 </dt>
3013 <dd>
3015 When using <em>git diff</em> to compare with work tree
3016 files, do not consider stat-only changes as changed.
3017 Instead, silently run <code>git update-index --refresh</code> to
3018 update the cached stat information for paths whose
3019 contents in the work tree match the contents in the
3020 index. This option defaults to true. Note that this
3021 affects only <em>git diff</em> Porcelain, and not lower level
3022 <em>diff</em> commands such as <em>git diff-files</em>.
3023 </p>
3024 </dd>
3025 <dt class="hdlist1">
3026 diff.dirstat
3027 </dt>
3028 <dd>
3030 A comma separated list of <code>--dirstat</code> parameters specifying the
3031 default behavior of the <code>--dirstat</code> option to <a href="git-diff.html">git-diff(1)</a>
3032 and friends. The defaults can be overridden on the command line
3033 (using <code>--dirstat=&lt;param1,param2,...&gt;</code>). The fallback defaults
3034 (when not changed by <code>diff.dirstat</code>) are <code>changes,noncumulative,3</code>.
3035 The following parameters are available:
3036 </p>
3037 <div class="openblock">
3038 <div class="content">
3039 <div class="dlist"><dl>
3040 <dt class="hdlist1">
3041 <code>changes</code>
3042 </dt>
3043 <dd>
3045 Compute the dirstat numbers by counting the lines that have been
3046 removed from the source, or added to the destination. This ignores
3047 the amount of pure code movements within a file. In other words,
3048 rearranging lines in a file is not counted as much as other changes.
3049 This is the default behavior when no parameter is given.
3050 </p>
3051 </dd>
3052 <dt class="hdlist1">
3053 <code>lines</code>
3054 </dt>
3055 <dd>
3057 Compute the dirstat numbers by doing the regular line-based diff
3058 analysis, and summing the removed/added line counts. (For binary
3059 files, count 64-byte chunks instead, since binary files have no
3060 natural concept of lines). This is a more expensive <code>--dirstat</code>
3061 behavior than the <code>changes</code> behavior, but it does count rearranged
3062 lines within a file as much as other changes. The resulting output
3063 is consistent with what you get from the other <code>--*stat</code> options.
3064 </p>
3065 </dd>
3066 <dt class="hdlist1">
3067 <code>files</code>
3068 </dt>
3069 <dd>
3071 Compute the dirstat numbers by counting the number of files changed.
3072 Each changed file counts equally in the dirstat analysis. This is
3073 the computationally cheapest <code>--dirstat</code> behavior, since it does
3074 not have to look at the file contents at all.
3075 </p>
3076 </dd>
3077 <dt class="hdlist1">
3078 <code>cumulative</code>
3079 </dt>
3080 <dd>
3082 Count changes in a child directory for the parent directory as well.
3083 Note that when using <code>cumulative</code>, the sum of the percentages
3084 reported may exceed 100%. The default (non-cumulative) behavior can
3085 be specified with the <code>noncumulative</code> parameter.
3086 </p>
3087 </dd>
3088 <dt class="hdlist1">
3089 &lt;limit&gt;
3090 </dt>
3091 <dd>
3093 An integer parameter specifies a cut-off percent (3% by default).
3094 Directories contributing less than this percentage of the changes
3095 are not shown in the output.
3096 </p>
3097 </dd>
3098 </dl></div>
3099 </div></div>
3100 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
3101 directories with less than 10% of the total amount of changed files,
3102 and accumulating child directory counts in the parent directories:
3103 <code>files,10,cumulative</code>.</p></div>
3104 </dd>
3105 <dt class="hdlist1">
3106 diff.statNameWidth
3107 </dt>
3108 <dd>
3110 Limit the width of the filename part in --stat output. If set, applies
3111 to all commands generating --stat output except format-patch.
3112 </p>
3113 </dd>
3114 <dt class="hdlist1">
3115 diff.statGraphWidth
3116 </dt>
3117 <dd>
3119 Limit the width of the graph part in --stat output. If set, applies
3120 to all commands generating --stat output except format-patch.
3121 </p>
3122 </dd>
3123 <dt class="hdlist1">
3124 diff.context
3125 </dt>
3126 <dd>
3128 Generate diffs with &lt;n&gt; lines of context instead of the default
3129 of 3. This value is overridden by the -U option.
3130 </p>
3131 </dd>
3132 <dt class="hdlist1">
3133 diff.interHunkContext
3134 </dt>
3135 <dd>
3137 Show the context between diff hunks, up to the specified number
3138 of lines, thereby fusing the hunks that are close to each other.
3139 This value serves as the default for the <code>--inter-hunk-context</code>
3140 command line option.
3141 </p>
3142 </dd>
3143 <dt class="hdlist1">
3144 diff.external
3145 </dt>
3146 <dd>
3148 If this config variable is set, diff generation is not
3149 performed using the internal diff machinery, but using the
3150 given command. Can be overridden with the &#8216;GIT_EXTERNAL_DIFF&#8217;
3151 environment variable. The command is called with parameters
3152 as described under "git Diffs" in <a href="git.html">git(1)</a>. Note: if
3153 you want to use an external diff program only on a subset of
3154 your files, you might want to use <a href="gitattributes.html">gitattributes(5)</a> instead.
3155 </p>
3156 </dd>
3157 <dt class="hdlist1">
3158 diff.ignoreSubmodules
3159 </dt>
3160 <dd>
3162 Sets the default value of --ignore-submodules. Note that this
3163 affects only <em>git diff</em> Porcelain, and not lower level <em>diff</em>
3164 commands such as <em>git diff-files</em>. <em>git checkout</em>
3165 and <em>git switch</em> also honor
3166 this setting when reporting uncommitted changes. Setting it to
3167 <em>all</em> disables the submodule summary normally shown by <em>git commit</em>
3168 and <em>git status</em> when <code>status.submoduleSummary</code> is set unless it is
3169 overridden by using the --ignore-submodules command-line option.
3170 The <em>git submodule</em> commands are not affected by this setting.
3171 By default this is set to untracked so that any untracked
3172 submodules are ignored.
3173 </p>
3174 </dd>
3175 <dt class="hdlist1">
3176 diff.mnemonicPrefix
3177 </dt>
3178 <dd>
3180 If set, <em>git diff</em> uses a prefix pair that is different from the
3181 standard "a/" and "b/" depending on what is being compared. When
3182 this configuration is in effect, reverse diff output also swaps
3183 the order of the prefixes:
3184 </p>
3185 <div class="dlist"><dl>
3186 <dt class="hdlist1">
3187 <code>git diff</code>
3188 </dt>
3189 <dd>
3191 compares the (i)ndex and the (w)ork tree;
3192 </p>
3193 </dd>
3194 <dt class="hdlist1">
3195 <code>git diff HEAD</code>
3196 </dt>
3197 <dd>
3199 compares a (c)ommit and the (w)ork tree;
3200 </p>
3201 </dd>
3202 <dt class="hdlist1">
3203 <code>git diff --cached</code>
3204 </dt>
3205 <dd>
3207 compares a (c)ommit and the (i)ndex;
3208 </p>
3209 </dd>
3210 <dt class="hdlist1">
3211 <code>git diff HEAD:file1 file2</code>
3212 </dt>
3213 <dd>
3215 compares an (o)bject and a (w)ork tree entity;
3216 </p>
3217 </dd>
3218 <dt class="hdlist1">
3219 <code>git diff --no-index a b</code>
3220 </dt>
3221 <dd>
3223 compares two non-git things (1) and (2).
3224 </p>
3225 </dd>
3226 </dl></div>
3227 </dd>
3228 <dt class="hdlist1">
3229 diff.noPrefix
3230 </dt>
3231 <dd>
3233 If set, <em>git diff</em> does not show any source or destination prefix.
3234 </p>
3235 </dd>
3236 <dt class="hdlist1">
3237 diff.srcPrefix
3238 </dt>
3239 <dd>
3241 If set, <em>git diff</em> uses this source prefix. Defaults to "a/".
3242 </p>
3243 </dd>
3244 <dt class="hdlist1">
3245 diff.dstPrefix
3246 </dt>
3247 <dd>
3249 If set, <em>git diff</em> uses this destination prefix. Defaults to "b/".
3250 </p>
3251 </dd>
3252 <dt class="hdlist1">
3253 diff.relative
3254 </dt>
3255 <dd>
3257 If set to <em>true</em>, <em>git diff</em> does not show changes outside of the directory
3258 and show pathnames relative to the current directory.
3259 </p>
3260 </dd>
3261 <dt class="hdlist1">
3262 diff.orderFile
3263 </dt>
3264 <dd>
3266 File indicating how to order files within a diff.
3267 See the <em>-O</em> option to <a href="git-diff.html">git-diff(1)</a> for details.
3268 If <code>diff.orderFile</code> is a relative pathname, it is treated as
3269 relative to the top of the working tree.
3270 </p>
3271 </dd>
3272 <dt class="hdlist1">
3273 diff.renameLimit
3274 </dt>
3275 <dd>
3277 The number of files to consider in the exhaustive portion of
3278 copy/rename detection; equivalent to the <em>git diff</em> option
3279 <code>-l</code>. If not set, the default value is currently 1000. This
3280 setting has no effect if rename detection is turned off.
3281 </p>
3282 </dd>
3283 <dt class="hdlist1">
3284 diff.renames
3285 </dt>
3286 <dd>
3288 Whether and how Git detects renames. If set to "false",
3289 rename detection is disabled. If set to "true", basic rename
3290 detection is enabled. If set to "copies" or "copy", Git will
3291 detect copies, as well. Defaults to true. Note that this
3292 affects only <em>git diff</em> Porcelain like <a href="git-diff.html">git-diff(1)</a> and
3293 <a href="git-log.html">git-log(1)</a>, and not lower level commands such as
3294 <a href="git-diff-files.html">git-diff-files(1)</a>.
3295 </p>
3296 </dd>
3297 <dt class="hdlist1">
3298 diff.suppressBlankEmpty
3299 </dt>
3300 <dd>
3302 A boolean to inhibit the standard behavior of printing a space
3303 before each empty output line. Defaults to false.
3304 </p>
3305 </dd>
3306 <dt class="hdlist1">
3307 diff.submodule
3308 </dt>
3309 <dd>
3311 Specify the format in which differences in submodules are
3312 shown. The "short" format just shows the names of the commits
3313 at the beginning and end of the range. The "log" format lists
3314 the commits in the range like <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code>
3315 does. The "diff" format shows an inline diff of the changed
3316 contents of the submodule. Defaults to "short".
3317 </p>
3318 </dd>
3319 <dt class="hdlist1">
3320 diff.wordRegex
3321 </dt>
3322 <dd>
3324 A POSIX Extended Regular Expression used to determine what is a "word"
3325 when performing word-by-word difference calculations. Character
3326 sequences that match the regular expression are "words", all other
3327 characters are <strong>ignorable</strong> whitespace.
3328 </p>
3329 </dd>
3330 <dt class="hdlist1">
3331 diff.&lt;driver&gt;.command
3332 </dt>
3333 <dd>
3335 The custom diff driver command. See <a href="gitattributes.html">gitattributes(5)</a>
3336 for details.
3337 </p>
3338 </dd>
3339 <dt class="hdlist1">
3340 diff.&lt;driver&gt;.xfuncname
3341 </dt>
3342 <dd>
3344 The regular expression that the diff driver should use to
3345 recognize the hunk header. A built-in pattern may also be used.
3346 See <a href="gitattributes.html">gitattributes(5)</a> for details.
3347 </p>
3348 </dd>
3349 <dt class="hdlist1">
3350 diff.&lt;driver&gt;.binary
3351 </dt>
3352 <dd>
3354 Set this option to true to make the diff driver treat files as
3355 binary. See <a href="gitattributes.html">gitattributes(5)</a> for details.
3356 </p>
3357 </dd>
3358 <dt class="hdlist1">
3359 diff.&lt;driver&gt;.textconv
3360 </dt>
3361 <dd>
3363 The command that the diff driver should call to generate the
3364 text-converted version of a file. The result of the
3365 conversion is used to generate a human-readable diff. See
3366 <a href="gitattributes.html">gitattributes(5)</a> for details.
3367 </p>
3368 </dd>
3369 <dt class="hdlist1">
3370 diff.&lt;driver&gt;.wordRegex
3371 </dt>
3372 <dd>
3374 The regular expression that the diff driver should use to
3375 split words in a line. See <a href="gitattributes.html">gitattributes(5)</a> for
3376 details.
3377 </p>
3378 </dd>
3379 <dt class="hdlist1">
3380 diff.&lt;driver&gt;.cachetextconv
3381 </dt>
3382 <dd>
3384 Set this option to true to make the diff driver cache the text
3385 conversion outputs. See <a href="gitattributes.html">gitattributes(5)</a> for details.
3386 </p>
3387 <div class="dlist"><dl>
3388 <dt class="hdlist1">
3389 <code>araxis</code>
3390 </dt>
3391 <dd>
3393 Use Araxis Merge (requires a graphical session)
3394 </p>
3395 </dd>
3396 <dt class="hdlist1">
3397 <code>bc</code>
3398 </dt>
3399 <dd>
3401 Use Beyond Compare (requires a graphical session)
3402 </p>
3403 </dd>
3404 <dt class="hdlist1">
3405 <code>bc3</code>
3406 </dt>
3407 <dd>
3409 Use Beyond Compare (requires a graphical session)
3410 </p>
3411 </dd>
3412 <dt class="hdlist1">
3413 <code>bc4</code>
3414 </dt>
3415 <dd>
3417 Use Beyond Compare (requires a graphical session)
3418 </p>
3419 </dd>
3420 <dt class="hdlist1">
3421 <code>codecompare</code>
3422 </dt>
3423 <dd>
3425 Use Code Compare (requires a graphical session)
3426 </p>
3427 </dd>
3428 <dt class="hdlist1">
3429 <code>deltawalker</code>
3430 </dt>
3431 <dd>
3433 Use DeltaWalker (requires a graphical session)
3434 </p>
3435 </dd>
3436 <dt class="hdlist1">
3437 <code>diffmerge</code>
3438 </dt>
3439 <dd>
3441 Use DiffMerge (requires a graphical session)
3442 </p>
3443 </dd>
3444 <dt class="hdlist1">
3445 <code>diffuse</code>
3446 </dt>
3447 <dd>
3449 Use Diffuse (requires a graphical session)
3450 </p>
3451 </dd>
3452 <dt class="hdlist1">
3453 <code>ecmerge</code>
3454 </dt>
3455 <dd>
3457 Use ECMerge (requires a graphical session)
3458 </p>
3459 </dd>
3460 <dt class="hdlist1">
3461 <code>emerge</code>
3462 </dt>
3463 <dd>
3465 Use Emacs' Emerge
3466 </p>
3467 </dd>
3468 <dt class="hdlist1">
3469 <code>examdiff</code>
3470 </dt>
3471 <dd>
3473 Use ExamDiff Pro (requires a graphical session)
3474 </p>
3475 </dd>
3476 <dt class="hdlist1">
3477 <code>guiffy</code>
3478 </dt>
3479 <dd>
3481 Use Guiffy&#8217;s Diff Tool (requires a graphical session)
3482 </p>
3483 </dd>
3484 <dt class="hdlist1">
3485 <code>gvimdiff</code>
3486 </dt>
3487 <dd>
3489 Use gVim (requires a graphical session)
3490 </p>
3491 </dd>
3492 <dt class="hdlist1">
3493 <code>kdiff3</code>
3494 </dt>
3495 <dd>
3497 Use KDiff3 (requires a graphical session)
3498 </p>
3499 </dd>
3500 <dt class="hdlist1">
3501 <code>kompare</code>
3502 </dt>
3503 <dd>
3505 Use Kompare (requires a graphical session)
3506 </p>
3507 </dd>
3508 <dt class="hdlist1">
3509 <code>meld</code>
3510 </dt>
3511 <dd>
3513 Use Meld (requires a graphical session)
3514 </p>
3515 </dd>
3516 <dt class="hdlist1">
3517 <code>nvimdiff</code>
3518 </dt>
3519 <dd>
3521 Use Neovim
3522 </p>
3523 </dd>
3524 <dt class="hdlist1">
3525 <code>opendiff</code>
3526 </dt>
3527 <dd>
3529 Use FileMerge (requires a graphical session)
3530 </p>
3531 </dd>
3532 <dt class="hdlist1">
3533 <code>p4merge</code>
3534 </dt>
3535 <dd>
3537 Use HelixCore P4Merge (requires a graphical session)
3538 </p>
3539 </dd>
3540 <dt class="hdlist1">
3541 <code>smerge</code>
3542 </dt>
3543 <dd>
3545 Use Sublime Merge (requires a graphical session)
3546 </p>
3547 </dd>
3548 <dt class="hdlist1">
3549 <code>tkdiff</code>
3550 </dt>
3551 <dd>
3553 Use TkDiff (requires a graphical session)
3554 </p>
3555 </dd>
3556 <dt class="hdlist1">
3557 <code>vimdiff</code>
3558 </dt>
3559 <dd>
3561 Use Vim
3562 </p>
3563 </dd>
3564 <dt class="hdlist1">
3565 <code>winmerge</code>
3566 </dt>
3567 <dd>
3569 Use WinMerge (requires a graphical session)
3570 </p>
3571 </dd>
3572 <dt class="hdlist1">
3573 <code>xxdiff</code>
3574 </dt>
3575 <dd>
3577 Use xxdiff (requires a graphical session)
3578 </p>
3579 </dd>
3580 </dl></div>
3581 </dd>
3582 <dt class="hdlist1">
3583 diff.indentHeuristic
3584 </dt>
3585 <dd>
3587 Set this option to <code>false</code> to disable the default heuristics
3588 that shift diff hunk boundaries to make patches easier to read.
3589 </p>
3590 </dd>
3591 <dt class="hdlist1">
3592 diff.algorithm
3593 </dt>
3594 <dd>
3596 Choose a diff algorithm. The variants are as follows:
3597 </p>
3598 <div class="openblock">
3599 <div class="content">
3600 <div class="dlist"><dl>
3601 <dt class="hdlist1">
3602 <code>default</code>, <code>myers</code>
3603 </dt>
3604 <dd>
3606 The basic greedy diff algorithm. Currently, this is the default.
3607 </p>
3608 </dd>
3609 <dt class="hdlist1">
3610 <code>minimal</code>
3611 </dt>
3612 <dd>
3614 Spend extra time to make sure the smallest possible diff is
3615 produced.
3616 </p>
3617 </dd>
3618 <dt class="hdlist1">
3619 <code>patience</code>
3620 </dt>
3621 <dd>
3623 Use "patience diff" algorithm when generating patches.
3624 </p>
3625 </dd>
3626 <dt class="hdlist1">
3627 <code>histogram</code>
3628 </dt>
3629 <dd>
3631 This algorithm extends the patience algorithm to "support
3632 low-occurrence common elements".
3633 </p>
3634 </dd>
3635 </dl></div>
3636 </div></div>
3637 </dd>
3638 <dt class="hdlist1">
3639 diff.wsErrorHighlight
3640 </dt>
3641 <dd>
3643 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
3644 lines of the diff. Multiple values are separated by comma,
3645 <code>none</code> resets previous values, <code>default</code> reset the list to
3646 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. The
3647 whitespace errors are colored with <code>color.diff.whitespace</code>.
3648 The command line option <code>--ws-error-highlight=&lt;kind&gt;</code>
3649 overrides this setting.
3650 </p>
3651 </dd>
3652 <dt class="hdlist1">
3653 diff.colorMoved
3654 </dt>
3655 <dd>
3657 If set to either a valid <code>&lt;mode&gt;</code> or a true value, moved lines
3658 in a diff are colored differently, for details of valid modes
3659 see <em>--color-moved</em> in <a href="git-diff.html">git-diff(1)</a>. If simply set to
3660 true the default color mode will be used. When set to false,
3661 moved lines are not colored.
3662 </p>
3663 </dd>
3664 <dt class="hdlist1">
3665 diff.colorMovedWS
3666 </dt>
3667 <dd>
3669 When moved lines are colored using e.g. the <code>diff.colorMoved</code> setting,
3670 this option controls the <code>&lt;mode&gt;</code> how spaces are treated.
3671 For details of valid modes see <em>--color-moved-ws</em> in <a href="git-diff.html">git-diff(1)</a>.
3672 </p>
3673 </dd>
3674 </dl></div>
3675 </div>
3676 </div>
3677 <div class="sect1">
3678 <h2 id="_see_also">SEE ALSO</h2>
3679 <div class="sectionbody">
3680 <div class="paragraph"><p>diff(1),
3681 <a href="git-difftool.html">git-difftool(1)</a>,
3682 <a href="git-log.html">git-log(1)</a>,
3683 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
3684 <a href="git-format-patch.html">git-format-patch(1)</a>,
3685 <a href="git-apply.html">git-apply(1)</a>,
3686 <a href="git-show.html">git-show(1)</a></p></div>
3687 </div>
3688 </div>
3689 <div class="sect1">
3690 <h2 id="_git">GIT</h2>
3691 <div class="sectionbody">
3692 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
3693 </div>
3694 </div>
3695 </div>
3696 <div id="footnotes"><hr /></div>
3697 <div id="footer">
3698 <div id="footer-text">
3699 Last updated
3700 2023-12-27 15:50:18 PST
3701 </div>
3702 </div>
3703 </body>
3704 </html>