Autogenerated HTML docs for v1.7.7-rc2-4-g5ec82
[git/jnareb-git.git] / git-diff.html
blobfbb1161ff442539946e1fbeeab10c9436cec3850
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.5.2" />
7 <title>git-diff(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 git-diff(1) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>git-diff -
578 Show changes between commits, commit and working tree, etc
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="verseblock">
586 <div class="verseblock-content"><em>git diff</em> [options] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
587 <em>git diff</em> [options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
588 <em>git diff</em> [options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
589 <em>git diff</em> [options] [--no-index] [--] &lt;path&gt; &lt;path&gt;</div>
590 <div class="verseblock-attribution">
591 </div></div>
592 </div>
593 <h2 id="_description">DESCRIPTION</h2>
594 <div class="sectionbody">
595 <div class="paragraph"><p>Show changes between the working tree and the index or a tree, changes
596 between the index and a tree, changes between two trees, or changes
597 between two files on disk.</p></div>
598 <div class="dlist"><dl>
599 <dt class="hdlist1">
600 <em>git diff</em> [--options] [--] [&lt;path&gt;&#8230;]
601 </dt>
602 <dd>
604 This form is to view the changes you made relative to
605 the index (staging area for the next commit). In other
606 words, the differences are what you <em>could</em> tell git to
607 further add to the index but you still haven&#8217;t. You can
608 stage these changes by using <a href="git-add.html">git-add(1)</a>.
609 </p>
610 <div class="paragraph"><p>If exactly two paths are given and at least one points outside
611 the current repository, <em>git diff</em> will compare the two files /
612 directories. This behavior can be forced by --no-index.</p></div>
613 </dd>
614 <dt class="hdlist1">
615 <em>git diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
616 </dt>
617 <dd>
619 This form is to view the changes you staged for the next
620 commit relative to the named &lt;commit&gt;. Typically you
621 would want comparison with the latest commit, so if you
622 do not give &lt;commit&gt;, it defaults to HEAD.
623 If HEAD does not exist (e.g. unborned branches) and
624 &lt;commit&gt; is not given, it shows all staged changes.
625 --staged is a synonym of --cached.
626 </p>
627 </dd>
628 <dt class="hdlist1">
629 <em>git diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
630 </dt>
631 <dd>
633 This form is to view the changes you have in your
634 working tree relative to the named &lt;commit&gt;. You can
635 use HEAD to compare it with the latest commit, or a
636 branch name to compare with the tip of a different
637 branch.
638 </p>
639 </dd>
640 <dt class="hdlist1">
641 <em>git diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
642 </dt>
643 <dd>
645 This is to view the changes between two arbitrary
646 &lt;commit&gt;.
647 </p>
648 </dd>
649 <dt class="hdlist1">
650 <em>git diff</em> [--options] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
651 </dt>
652 <dd>
654 This is synonymous to the previous form. If &lt;commit&gt; on
655 one side is omitted, it will have the same effect as
656 using HEAD instead.
657 </p>
658 </dd>
659 <dt class="hdlist1">
660 <em>git diff</em> [--options] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
661 </dt>
662 <dd>
664 This form is to view the changes on the branch containing
665 and up to the second &lt;commit&gt;, starting at a common ancestor
666 of both &lt;commit&gt;. "git diff A...B" is equivalent to
667 "git diff $(git-merge-base A B) B". You can omit any one
668 of &lt;commit&gt;, which has the same effect as using HEAD instead.
669 </p>
670 </dd>
671 </dl></div>
672 <div class="paragraph"><p>Just in case if you are doing something exotic, it should be
673 noted that all of the &lt;commit&gt; in the above description, except
674 in the last two forms that use ".." notations, can be any
675 &lt;tree&gt;. The third form (<em>git diff &lt;commit&gt; &lt;commit&gt;</em>) can also
676 be used to compare two &lt;blob&gt; objects.</p></div>
677 <div class="paragraph"><p>For a more complete list of ways to spell &lt;commit&gt;, see
678 "SPECIFYING REVISIONS" section in <a href="gitrevisions.html">gitrevisions(7)</a>.
679 However, "diff" is about comparing two <em>endpoints</em>, not ranges,
680 and the range notations ("&lt;commit&gt;..&lt;commit&gt;" and
681 "&lt;commit&gt;...&lt;commit&gt;") do not mean a range as defined in the
682 "SPECIFYING RANGES" section in <a href="gitrevisions.html">gitrevisions(7)</a>.</p></div>
683 </div>
684 <h2 id="_options">OPTIONS</h2>
685 <div class="sectionbody">
686 <div class="dlist"><dl>
687 <dt class="hdlist1">
689 </dt>
690 <dt class="hdlist1">
692 </dt>
693 <dt class="hdlist1">
694 --patch
695 </dt>
696 <dd>
698 Generate patch (see section on generating patches).
699 This is the default.
700 </p>
701 </dd>
702 <dt class="hdlist1">
703 -U&lt;n&gt;
704 </dt>
705 <dt class="hdlist1">
706 --unified=&lt;n&gt;
707 </dt>
708 <dd>
710 Generate diffs with &lt;n&gt; lines of context instead of
711 the usual three.
712 Implies <tt>-p</tt>.
713 </p>
714 </dd>
715 <dt class="hdlist1">
716 --raw
717 </dt>
718 <dd>
720 Generate the raw format.
722 </p>
723 </dd>
724 <dt class="hdlist1">
725 --patch-with-raw
726 </dt>
727 <dd>
729 Synonym for <tt>-p --raw</tt>.
730 </p>
731 </dd>
732 <dt class="hdlist1">
733 --patience
734 </dt>
735 <dd>
737 Generate a diff using the "patience diff" algorithm.
738 </p>
739 </dd>
740 <dt class="hdlist1">
741 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
742 </dt>
743 <dd>
745 Generate a diffstat. You can override the default
746 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
747 The width of the filename part can be controlled by
748 giving another width to it separated by a comma.
749 By giving a third parameter <tt>&lt;count&gt;</tt>, you can limit the
750 output to the first <tt>&lt;count&gt;</tt> lines, followed by
751 <tt>&#8230;</tt> if there are more.
752 </p>
753 <div class="paragraph"><p>These parameters can also be set individually with <tt>--stat-width=&lt;width&gt;</tt>,
754 <tt>--stat-name-width=&lt;name-width&gt;</tt> and <tt>--stat-count=&lt;count&gt;</tt>.</p></div>
755 </dd>
756 <dt class="hdlist1">
757 --numstat
758 </dt>
759 <dd>
761 Similar to <tt>--stat</tt>, but shows number of added and
762 deleted lines in decimal notation and pathname without
763 abbreviation, to make it more machine friendly. For
764 binary files, outputs two <tt>-</tt> instead of saying
765 <tt>0 0</tt>.
766 </p>
767 </dd>
768 <dt class="hdlist1">
769 --shortstat
770 </dt>
771 <dd>
773 Output only the last line of the <tt>--stat</tt> format containing total
774 number of modified files, as well as number of added and deleted
775 lines.
776 </p>
777 </dd>
778 <dt class="hdlist1">
779 --dirstat[=&lt;param1,param2,&#8230;&gt;]
780 </dt>
781 <dd>
783 Output the distribution of relative amount of changes for each
784 sub-directory. The behavior of <tt>--dirstat</tt> can be customized by
785 passing it a comma separated list of parameters.
786 The defaults are controlled by the <tt>diff.dirstat</tt> configuration
787 variable (see <a href="git-config.html">git-config(1)</a>).
788 The following parameters are available:
789 </p>
790 <div class="dlist"><dl>
791 <dt class="hdlist1">
792 <tt>changes</tt>
793 </dt>
794 <dd>
796 Compute the dirstat numbers by counting the lines that have been
797 removed from the source, or added to the destination. This ignores
798 the amount of pure code movements within a file. In other words,
799 rearranging lines in a file is not counted as much as other changes.
800 This is the default behavior when no parameter is given.
801 </p>
802 </dd>
803 <dt class="hdlist1">
804 <tt>lines</tt>
805 </dt>
806 <dd>
808 Compute the dirstat numbers by doing the regular line-based diff
809 analysis, and summing the removed/added line counts. (For binary
810 files, count 64-byte chunks instead, since binary files have no
811 natural concept of lines). This is a more expensive <tt>--dirstat</tt>
812 behavior than the <tt>changes</tt> behavior, but it does count rearranged
813 lines within a file as much as other changes. The resulting output
814 is consistent with what you get from the other <tt>--*stat</tt> options.
815 </p>
816 </dd>
817 <dt class="hdlist1">
818 <tt>files</tt>
819 </dt>
820 <dd>
822 Compute the dirstat numbers by counting the number of files changed.
823 Each changed file counts equally in the dirstat analysis. This is
824 the computationally cheapest <tt>--dirstat</tt> behavior, since it does
825 not have to look at the file contents at all.
826 </p>
827 </dd>
828 <dt class="hdlist1">
829 <tt>cumulative</tt>
830 </dt>
831 <dd>
833 Count changes in a child directory for the parent directory as well.
834 Note that when using <tt>cumulative</tt>, the sum of the percentages
835 reported may exceed 100%. The default (non-cumulative) behavior can
836 be specified with the <tt>noncumulative</tt> parameter.
837 </p>
838 </dd>
839 <dt class="hdlist1">
840 &lt;limit&gt;
841 </dt>
842 <dd>
844 An integer parameter specifies a cut-off percent (3% by default).
845 Directories contributing less than this percentage of the changes
846 are not shown in the output.
847 </p>
848 </dd>
849 </dl></div>
850 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
851 directories with less than 10% of the total amount of changed files,
852 and accumulating child directory counts in the parent directories:
853 <tt>--dirstat=files,10,cumulative</tt>.</p></div>
854 </dd>
855 <dt class="hdlist1">
856 --summary
857 </dt>
858 <dd>
860 Output a condensed summary of extended header information
861 such as creations, renames and mode changes.
862 </p>
863 </dd>
864 <dt class="hdlist1">
865 --patch-with-stat
866 </dt>
867 <dd>
869 Synonym for <tt>-p --stat</tt>.
870 </p>
871 </dd>
872 <dt class="hdlist1">
874 </dt>
875 <dd>
877 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
878 given, do not munge pathnames and use NULs as output field terminators.
879 </p>
880 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
881 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
882 respectively, and the pathname will be enclosed in double quotes if
883 any of those replacements occurred.</p></div>
884 </dd>
885 <dt class="hdlist1">
886 --name-only
887 </dt>
888 <dd>
890 Show only names of changed files.
891 </p>
892 </dd>
893 <dt class="hdlist1">
894 --name-status
895 </dt>
896 <dd>
898 Show only names and status of changed files. See the description
899 of the <tt>--diff-filter</tt> option on what the status letters mean.
900 </p>
901 </dd>
902 <dt class="hdlist1">
903 --submodule[=&lt;format&gt;]
904 </dt>
905 <dd>
907 Chose the output format for submodule differences. &lt;format&gt; can be one of
908 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
909 is used when this option is not given. <em>log</em> is the default value for this
910 option and lists the commits in that commit range like the <em>summary</em>
911 option of <a href="git-submodule.html">git-submodule(1)</a> does.
912 </p>
913 </dd>
914 <dt class="hdlist1">
915 --color[=&lt;when&gt;]
916 </dt>
917 <dd>
919 Show colored diff.
920 The value must be <tt>always</tt> (the default for <tt>&lt;when&gt;</tt>), <tt>never</tt>, or <tt>auto</tt>.
921 The default value is <tt>never</tt>.
922 It can be changed by the <tt>color.ui</tt> and <tt>color.diff</tt>
923 configuration settings.
924 </p>
925 </dd>
926 <dt class="hdlist1">
927 --no-color
928 </dt>
929 <dd>
931 Turn off colored diff.
932 This can be used to override configuration settings.
933 It is the same as <tt>--color=never</tt>.
934 </p>
935 </dd>
936 <dt class="hdlist1">
937 --word-diff[=&lt;mode&gt;]
938 </dt>
939 <dd>
941 Show a word diff, using the &lt;mode&gt; to delimit changed words.
942 By default, words are delimited by whitespace; see
943 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
944 must be one of:
945 </p>
946 <div class="dlist"><dl>
947 <dt class="hdlist1">
948 color
949 </dt>
950 <dd>
952 Highlight changed words using only colors. Implies <tt>--color</tt>.
953 </p>
954 </dd>
955 <dt class="hdlist1">
956 plain
957 </dt>
958 <dd>
960 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
961 attempts to escape the delimiters if they appear in the input,
962 so the output may be ambiguous.
963 </p>
964 </dd>
965 <dt class="hdlist1">
966 porcelain
967 </dt>
968 <dd>
970 Use a special line-based format intended for script
971 consumption. Added/removed/unchanged runs are printed in the
972 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
973 character at the beginning of the line and extending to the
974 end of the line. Newlines in the input are represented by a
975 tilde <tt>~</tt> on a line of its own.
976 </p>
977 </dd>
978 <dt class="hdlist1">
979 none
980 </dt>
981 <dd>
983 Disable word diff again.
984 </p>
985 </dd>
986 </dl></div>
987 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
988 highlight the changed parts in all modes if enabled.</p></div>
989 </dd>
990 <dt class="hdlist1">
991 --word-diff-regex=&lt;regex&gt;
992 </dt>
993 <dd>
995 Use &lt;regex&gt; to decide what a word is, instead of considering
996 runs of non-whitespace to be a word. Also implies
997 <tt>--word-diff</tt> unless it was already enabled.
998 </p>
999 <div class="paragraph"><p>Every non-overlapping match of the
1000 &lt;regex&gt; is considered a word. Anything between these matches is
1001 considered whitespace and ignored(!) for the purposes of finding
1002 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
1003 expression to make sure that it matches all non-whitespace characters.
1004 A match that contains a newline is silently truncated(!) at the
1005 newline.</p></div>
1006 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1007 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1008 overrides any diff driver or configuration setting. Diff drivers
1009 override configuration settings.</p></div>
1010 </dd>
1011 <dt class="hdlist1">
1012 --color-words[=&lt;regex&gt;]
1013 </dt>
1014 <dd>
1016 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
1017 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
1018 </p>
1019 </dd>
1020 <dt class="hdlist1">
1021 --no-renames
1022 </dt>
1023 <dd>
1025 Turn off rename detection, even when the configuration
1026 file gives the default to do so.
1027 </p>
1028 </dd>
1029 <dt class="hdlist1">
1030 --check
1031 </dt>
1032 <dd>
1034 Warn if changes introduce whitespace errors. What are
1035 considered whitespace errors is controlled by <tt>core.whitespace</tt>
1036 configuration. By default, trailing whitespaces (including
1037 lines that solely consist of whitespaces) and a space character
1038 that is immediately followed by a tab character inside the
1039 initial indent of the line are considered whitespace errors.
1040 Exits with non-zero status if problems are found. Not compatible
1041 with --exit-code.
1042 </p>
1043 </dd>
1044 <dt class="hdlist1">
1045 --full-index
1046 </dt>
1047 <dd>
1049 Instead of the first handful of characters, show the full
1050 pre- and post-image blob object names on the "index"
1051 line when generating patch format output.
1052 </p>
1053 </dd>
1054 <dt class="hdlist1">
1055 --binary
1056 </dt>
1057 <dd>
1059 In addition to <tt>--full-index</tt>, output a binary diff that
1060 can be applied with <tt>git-apply</tt>.
1061 </p>
1062 </dd>
1063 <dt class="hdlist1">
1064 --abbrev[=&lt;n&gt;]
1065 </dt>
1066 <dd>
1068 Instead of showing the full 40-byte hexadecimal object
1069 name in diff-raw format output and diff-tree header
1070 lines, show only a partial prefix. This is
1071 independent of the <tt>--full-index</tt> option above, which controls
1072 the diff-patch output format. Non default number of
1073 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
1074 </p>
1075 </dd>
1076 <dt class="hdlist1">
1077 -B[&lt;n&gt;][/&lt;m&gt;]
1078 </dt>
1079 <dt class="hdlist1">
1080 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1081 </dt>
1082 <dd>
1084 Break complete rewrite changes into pairs of delete and
1085 create. This serves two purposes:
1086 </p>
1087 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1088 not as a series of deletion and insertion mixed together with a very
1089 few lines that happen to match textually as the context, but as a
1090 single deletion of everything old followed by a single insertion of
1091 everything new, and the number <tt>m</tt> controls this aspect of the -B
1092 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
1093 original should remain in the result for git to consider it a total
1094 rewrite (i.e. otherwise the resulting patch will be a series of
1095 deletion and insertion mixed together with context lines).</p></div>
1096 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1097 source of a rename (usually -M only considers a file that disappeared
1098 as the source of a rename), and the number <tt>n</tt> controls this aspect of
1099 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
1100 addition and deletion compared to 20% or more of the file&#8217;s size are
1101 eligible for being picked up as a possible source of a rename to
1102 another file.</p></div>
1103 </dd>
1104 <dt class="hdlist1">
1105 -M[&lt;n&gt;]
1106 </dt>
1107 <dt class="hdlist1">
1108 --find-renames[=&lt;n&gt;]
1109 </dt>
1110 <dd>
1112 Detect renames.
1113 If <tt>n</tt> is specified, it is a threshold on the similarity
1114 index (i.e. amount of addition/deletions compared to the
1115 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
1116 delete/add pair to be a rename if more than 90% of the file
1117 hasn&#8217;t changed.
1118 </p>
1119 </dd>
1120 <dt class="hdlist1">
1121 -C[&lt;n&gt;]
1122 </dt>
1123 <dt class="hdlist1">
1124 --find-copies[=&lt;n&gt;]
1125 </dt>
1126 <dd>
1128 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
1129 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
1130 </p>
1131 </dd>
1132 <dt class="hdlist1">
1133 --find-copies-harder
1134 </dt>
1135 <dd>
1137 For performance reasons, by default, <tt>-C</tt> option finds copies only
1138 if the original file of the copy was modified in the same
1139 changeset. This flag makes the command
1140 inspect unmodified files as candidates for the source of
1141 copy. This is a very expensive operation for large
1142 projects, so use it with caution. Giving more than one
1143 <tt>-C</tt> option has the same effect.
1144 </p>
1145 </dd>
1146 <dt class="hdlist1">
1148 </dt>
1149 <dt class="hdlist1">
1150 --irreversible-delete
1151 </dt>
1152 <dd>
1154 Omit the preimage for deletes, i.e. print only the header but not
1155 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
1156 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
1157 solely for people who want to just concentrate on reviewing the
1158 text after the change. In addition, the output obviously lack
1159 enough information to apply such a patch in reverse, even manually,
1160 hence the name of the option.
1161 </p>
1162 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
1163 of a delete/create pair.</p></div>
1164 </dd>
1165 <dt class="hdlist1">
1166 -l&lt;num&gt;
1167 </dt>
1168 <dd>
1170 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
1171 is the number of potential rename/copy targets. This
1172 option prevents rename/copy detection from running if
1173 the number of rename/copy targets exceeds the specified
1174 number.
1175 </p>
1176 </dd>
1177 <dt class="hdlist1">
1178 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1179 </dt>
1180 <dd>
1182 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
1183 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
1184 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
1185 are Unmerged (<tt>U</tt>), are
1186 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
1187 Any combination of the filter characters (including none) can be used.
1188 When <tt>*</tt> (All-or-none) is added to the combination, all
1189 paths are selected if there is any file that matches
1190 other criteria in the comparison; if there is no file
1191 that matches other criteria, nothing is selected.
1192 </p>
1193 </dd>
1194 <dt class="hdlist1">
1195 -S&lt;string&gt;
1196 </dt>
1197 <dd>
1199 Look for differences that introduce or remove an instance of
1200 &lt;string&gt;. Note that this is different than the string simply
1201 appearing in diff output; see the <em>pickaxe</em> entry in
1202 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
1203 </p>
1204 </dd>
1205 <dt class="hdlist1">
1206 -G&lt;regex&gt;
1207 </dt>
1208 <dd>
1210 Look for differences whose added or removed line matches
1211 the given &lt;regex&gt;.
1212 </p>
1213 </dd>
1214 <dt class="hdlist1">
1215 --pickaxe-all
1216 </dt>
1217 <dd>
1219 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
1220 changeset, not just the files that contain the change
1221 in &lt;string&gt;.
1222 </p>
1223 </dd>
1224 <dt class="hdlist1">
1225 --pickaxe-regex
1226 </dt>
1227 <dd>
1229 Make the &lt;string&gt; not a plain string but an extended POSIX
1230 regex to match.
1231 </p>
1232 </dd>
1233 <dt class="hdlist1">
1234 -O&lt;orderfile&gt;
1235 </dt>
1236 <dd>
1238 Output the patch in the order specified in the
1239 &lt;orderfile&gt;, which has one shell glob pattern per line.
1240 </p>
1241 </dd>
1242 <dt class="hdlist1">
1244 </dt>
1245 <dd>
1247 Swap two inputs; that is, show differences from index or
1248 on-disk file to tree contents.
1249 </p>
1250 </dd>
1251 <dt class="hdlist1">
1252 --relative[=&lt;path&gt;]
1253 </dt>
1254 <dd>
1256 When run from a subdirectory of the project, it can be
1257 told to exclude changes outside the directory and show
1258 pathnames relative to it with this option. When you are
1259 not in a subdirectory (e.g. in a bare repository), you
1260 can name which subdirectory to make the output relative
1261 to by giving a &lt;path&gt; as an argument.
1262 </p>
1263 </dd>
1264 <dt class="hdlist1">
1266 </dt>
1267 <dt class="hdlist1">
1268 --text
1269 </dt>
1270 <dd>
1272 Treat all files as text.
1273 </p>
1274 </dd>
1275 <dt class="hdlist1">
1276 --ignore-space-at-eol
1277 </dt>
1278 <dd>
1280 Ignore changes in whitespace at EOL.
1281 </p>
1282 </dd>
1283 <dt class="hdlist1">
1285 </dt>
1286 <dt class="hdlist1">
1287 --ignore-space-change
1288 </dt>
1289 <dd>
1291 Ignore changes in amount of whitespace. This ignores whitespace
1292 at line end, and considers all other sequences of one or
1293 more whitespace characters to be equivalent.
1294 </p>
1295 </dd>
1296 <dt class="hdlist1">
1298 </dt>
1299 <dt class="hdlist1">
1300 --ignore-all-space
1301 </dt>
1302 <dd>
1304 Ignore whitespace when comparing lines. This ignores
1305 differences even if one line has whitespace where the other
1306 line has none.
1307 </p>
1308 </dd>
1309 <dt class="hdlist1">
1310 --inter-hunk-context=&lt;lines&gt;
1311 </dt>
1312 <dd>
1314 Show the context between diff hunks, up to the specified number
1315 of lines, thereby fusing hunks that are close to each other.
1316 </p>
1317 </dd>
1318 <dt class="hdlist1">
1319 --exit-code
1320 </dt>
1321 <dd>
1323 Make the program exit with codes similar to diff(1).
1324 That is, it exits with 1 if there were differences and
1325 0 means no differences.
1326 </p>
1327 </dd>
1328 <dt class="hdlist1">
1329 --quiet
1330 </dt>
1331 <dd>
1333 Disable all output of the program. Implies <tt>--exit-code</tt>.
1334 </p>
1335 </dd>
1336 <dt class="hdlist1">
1337 --ext-diff
1338 </dt>
1339 <dd>
1341 Allow an external diff helper to be executed. If you set an
1342 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1343 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1344 </p>
1345 </dd>
1346 <dt class="hdlist1">
1347 --no-ext-diff
1348 </dt>
1349 <dd>
1351 Disallow external diff drivers.
1352 </p>
1353 </dd>
1354 <dt class="hdlist1">
1355 --textconv
1356 </dt>
1357 <dt class="hdlist1">
1358 --no-textconv
1359 </dt>
1360 <dd>
1362 Allow (or disallow) external text conversion filters to be run
1363 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1364 details. Because textconv filters are typically a one-way
1365 conversion, the resulting diff is suitable for human
1366 consumption, but cannot be applied. For this reason, textconv
1367 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1368 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1369 diff plumbing commands.
1370 </p>
1371 </dd>
1372 <dt class="hdlist1">
1373 --ignore-submodules[=&lt;when&gt;]
1374 </dt>
1375 <dd>
1377 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1378 either "none", "untracked", "dirty" or "all", which is the default
1379 Using "none" will consider the submodule modified when it either contains
1380 untracked or modified files or its HEAD differs from the commit recorded
1381 in the superproject and can be used to override any settings of the
1382 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1383 "untracked" is used submodules are not considered dirty when they only
1384 contain untracked content (but they are still scanned for modified
1385 content). Using "dirty" ignores all changes to the work tree of submodules,
1386 only changes to the commits stored in the superproject are shown (this was
1387 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1388 </p>
1389 </dd>
1390 <dt class="hdlist1">
1391 --src-prefix=&lt;prefix&gt;
1392 </dt>
1393 <dd>
1395 Show the given source prefix instead of "a/".
1396 </p>
1397 </dd>
1398 <dt class="hdlist1">
1399 --dst-prefix=&lt;prefix&gt;
1400 </dt>
1401 <dd>
1403 Show the given destination prefix instead of "b/".
1404 </p>
1405 </dd>
1406 <dt class="hdlist1">
1407 --no-prefix
1408 </dt>
1409 <dd>
1411 Do not show any source or destination prefix.
1412 </p>
1413 </dd>
1414 </dl></div>
1415 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1416 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1417 <div class="dlist"><dl>
1418 <dt class="hdlist1">
1419 &lt;path&gt;&#8230;
1420 </dt>
1421 <dd>
1423 The &lt;paths&gt; parameters, when given, are used to limit
1424 the diff to the named paths (you can give directory
1425 names and get diff for all files under them).
1426 </p>
1427 </dd>
1428 </dl></div>
1429 </div>
1430 <h2 id="_raw_output_format">Raw output format</h2>
1431 <div class="sectionbody">
1432 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1433 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1434 <div class="paragraph"><p>These commands all compare two sets of things; what is
1435 compared differs:</p></div>
1436 <div class="dlist"><dl>
1437 <dt class="hdlist1">
1438 git-diff-index &lt;tree-ish&gt;
1439 </dt>
1440 <dd>
1442 compares the &lt;tree-ish&gt; and the files on the filesystem.
1443 </p>
1444 </dd>
1445 <dt class="hdlist1">
1446 git-diff-index --cached &lt;tree-ish&gt;
1447 </dt>
1448 <dd>
1450 compares the &lt;tree-ish&gt; and the index.
1451 </p>
1452 </dd>
1453 <dt class="hdlist1">
1454 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1455 </dt>
1456 <dd>
1458 compares the trees named by the two arguments.
1459 </p>
1460 </dd>
1461 <dt class="hdlist1">
1462 git-diff-files [&lt;pattern&gt;&#8230;]
1463 </dt>
1464 <dd>
1466 compares the index and the files on the filesystem.
1467 </p>
1468 </dd>
1469 </dl></div>
1470 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1471 what is being compared. After that, all the commands print one output
1472 line per changed file.</p></div>
1473 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1474 <div class="listingblock">
1475 <div class="content">
1476 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1477 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1478 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1479 create :000000 100644 0000000... 1234567... A file4
1480 delete :100644 000000 1234567... 0000000... D file5
1481 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1482 </div></div>
1483 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1484 <div class="olist arabic"><ol class="arabic">
1485 <li>
1487 a colon.
1488 </p>
1489 </li>
1490 <li>
1492 mode for "src"; 000000 if creation or unmerged.
1493 </p>
1494 </li>
1495 <li>
1497 a space.
1498 </p>
1499 </li>
1500 <li>
1502 mode for "dst"; 000000 if deletion or unmerged.
1503 </p>
1504 </li>
1505 <li>
1507 a space.
1508 </p>
1509 </li>
1510 <li>
1512 sha1 for "src"; 0{40} if creation or unmerged.
1513 </p>
1514 </li>
1515 <li>
1517 a space.
1518 </p>
1519 </li>
1520 <li>
1522 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1523 </p>
1524 </li>
1525 <li>
1527 a space.
1528 </p>
1529 </li>
1530 <li>
1532 status, followed by optional "score" number.
1533 </p>
1534 </li>
1535 <li>
1537 a tab or a NUL when <em>-z</em> option is used.
1538 </p>
1539 </li>
1540 <li>
1542 path for "src"
1543 </p>
1544 </li>
1545 <li>
1547 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1548 </p>
1549 </li>
1550 <li>
1552 path for "dst"; only exists for C or R.
1553 </p>
1554 </li>
1555 <li>
1557 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1558 </p>
1559 </li>
1560 </ol></div>
1561 <div class="paragraph"><p>Possible status letters are:</p></div>
1562 <div class="ulist"><ul>
1563 <li>
1565 A: addition of a file
1566 </p>
1567 </li>
1568 <li>
1570 C: copy of a file into a new one
1571 </p>
1572 </li>
1573 <li>
1575 D: deletion of a file
1576 </p>
1577 </li>
1578 <li>
1580 M: modification of the contents or mode of a file
1581 </p>
1582 </li>
1583 <li>
1585 R: renaming of a file
1586 </p>
1587 </li>
1588 <li>
1590 T: change in the type of the file
1591 </p>
1592 </li>
1593 <li>
1595 U: file is unmerged (you must complete the merge before it can
1596 be committed)
1597 </p>
1598 </li>
1599 <li>
1601 X: "unknown" change type (most probably a bug, please report it)
1602 </p>
1603 </li>
1604 </ul></div>
1605 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1606 percentage of similarity between the source and target of the move or
1607 copy), and are the only ones to be so.</p></div>
1608 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1609 and it is out of sync with the index.</p></div>
1610 <div class="paragraph"><p>Example:</p></div>
1611 <div class="listingblock">
1612 <div class="content">
1613 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1614 </div></div>
1615 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1616 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1617 respectively.</p></div>
1618 </div>
1619 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1620 <div class="sectionbody">
1621 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1622 can take <em>-c</em> or <em>--cc</em> option
1623 to generate diff output also for merge commits. The output differs
1624 from the format described above in the following way:</p></div>
1625 <div class="olist arabic"><ol class="arabic">
1626 <li>
1628 there is a colon for each parent
1629 </p>
1630 </li>
1631 <li>
1633 there are more "src" modes and "src" sha1
1634 </p>
1635 </li>
1636 <li>
1638 status is concatenated status characters for each parent
1639 </p>
1640 </li>
1641 <li>
1643 no optional "score" number
1644 </p>
1645 </li>
1646 <li>
1648 single path, only for "dst"
1649 </p>
1650 </li>
1651 </ol></div>
1652 <div class="paragraph"><p>Example:</p></div>
1653 <div class="listingblock">
1654 <div class="content">
1655 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1656 </div></div>
1657 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1658 all parents.</p></div>
1659 </div>
1660 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1661 <div class="sectionbody">
1662 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1663 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1664 "git log" with the "-p" option, they
1665 do not produce the output described above; instead they produce a
1666 patch file. You can customize the creation of such patches via the
1667 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1668 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1669 diff format:</p></div>
1670 <div class="olist arabic"><ol class="arabic">
1671 <li>
1673 It is preceded with a "git diff" header that looks like this:
1674 </p>
1675 <div class="literalblock">
1676 <div class="content">
1677 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1678 </div></div>
1679 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1680 involved. Especially, even for a creation or a deletion,
1681 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1682 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1683 name of the source file of the rename/copy and the name of
1684 the file that rename/copy produces, respectively.</p></div>
1685 </li>
1686 <li>
1688 It is followed by one or more extended header lines:
1689 </p>
1690 <div class="literalblock">
1691 <div class="content">
1692 <pre><tt>old mode &lt;mode&gt;
1693 new mode &lt;mode&gt;
1694 deleted file mode &lt;mode&gt;
1695 new file mode &lt;mode&gt;
1696 copy from &lt;path&gt;
1697 copy to &lt;path&gt;
1698 rename from &lt;path&gt;
1699 rename to &lt;path&gt;
1700 similarity index &lt;number&gt;
1701 dissimilarity index &lt;number&gt;
1702 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1703 </div></div>
1704 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1705 and file permission bits.</p></div>
1706 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1707 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1708 the dissimilarity index is the percentage of changed lines. It
1709 is a rounded down integer, followed by a percent sign. The
1710 similarity index value of 100% is thus reserved for two equal
1711 files, while 100% dissimilarity means that no line from the old
1712 file made it into the new one.</p></div>
1713 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1714 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1715 separate lines indicate the old and the new mode.</p></div>
1716 </li>
1717 <li>
1719 TAB, LF, double quote and backslash characters in pathnames
1720 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1721 If there is need for such substitution then the whole
1722 pathname is put in double quotes.
1723 </p>
1724 </li>
1725 <li>
1727 All the <tt>file1</tt> files in the output refer to files before the
1728 commit, and all the <tt>file2</tt> files refer to files after the commit.
1729 It is incorrect to apply each change to each file sequentially. For
1730 example, this patch will swap a and b:
1731 </p>
1732 <div class="literalblock">
1733 <div class="content">
1734 <pre><tt>diff --git a/a b/b
1735 rename from a
1736 rename to b
1737 diff --git a/b b/a
1738 rename from b
1739 rename to a</tt></pre>
1740 </div></div>
1741 </li>
1742 </ol></div>
1743 </div>
1744 <h2 id="_combined_diff_format">combined diff format</h2>
1745 <div class="sectionbody">
1746 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1747 produce a <em>combined diff</em> when showing a merge. This is the default
1748 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1749 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1750 of these commands to force generation of diffs with individual parents
1751 of a merge.</p></div>
1752 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1753 <div class="listingblock">
1754 <div class="content">
1755 <pre><tt>diff --combined describe.c
1756 index fabadb8,cc95eb0..4866510
1757 --- a/describe.c
1758 +++ b/describe.c
1759 @@@ -98,20 -98,12 +98,20 @@@
1760 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1763 - static void describe(char *arg)
1764 -static void describe(struct commit *cmit, int last_one)
1765 ++static void describe(char *arg, int last_one)
1767 + unsigned char sha1[20];
1768 + struct commit *cmit;
1769 struct commit_list *list;
1770 static int initialized = 0;
1771 struct commit_name *n;
1773 + if (get_sha1(arg, sha1) &lt; 0)
1774 + usage(describe_usage);
1775 + cmit = lookup_commit_reference(sha1);
1776 + if (!cmit)
1777 + usage(describe_usage);
1779 if (!initialized) {
1780 initialized = 1;
1781 for_each_ref(get_name);</tt></pre>
1782 </div></div>
1783 <div class="olist arabic"><ol class="arabic">
1784 <li>
1786 It is preceded with a "git diff" header, that looks like
1787 this (when <em>-c</em> option is used):
1788 </p>
1789 <div class="literalblock">
1790 <div class="content">
1791 <pre><tt>diff --combined file</tt></pre>
1792 </div></div>
1793 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1794 <div class="literalblock">
1795 <div class="content">
1796 <pre><tt>diff --cc file</tt></pre>
1797 </div></div>
1798 </li>
1799 <li>
1801 It is followed by one or more extended header lines
1802 (this example shows a merge with two parents):
1803 </p>
1804 <div class="literalblock">
1805 <div class="content">
1806 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1807 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1808 new file mode &lt;mode&gt;
1809 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1810 </div></div>
1811 <div class="paragraph"><p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
1812 the &lt;mode&gt; is different from the rest. Extended headers with
1813 information about detected contents movement (renames and
1814 copying detection) are designed to work with diff of two
1815 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1816 </li>
1817 <li>
1819 It is followed by two-line from-file/to-file header
1820 </p>
1821 <div class="literalblock">
1822 <div class="content">
1823 <pre><tt>--- a/file
1824 +++ b/file</tt></pre>
1825 </div></div>
1826 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1827 format, <tt>/dev/null</tt> is used to signal created or deleted
1828 files.</p></div>
1829 </li>
1830 <li>
1832 Chunk header format is modified to prevent people from
1833 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1834 was created for review of merge commit changes, and was not
1835 meant for apply. The change is similar to the change in the
1836 extended <em>index</em> header:
1837 </p>
1838 <div class="literalblock">
1839 <div class="content">
1840 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1841 </div></div>
1842 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1843 header for combined diff format.</p></div>
1844 </li>
1845 </ol></div>
1846 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1847 files A and B with a single column that has <tt>-</tt> (minus&#8201;&#8212;&#8201;appears in A but removed in B), <tt>+</tt> (plus&#8201;&#8212;&#8201;missing in A but
1848 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1849 compares two or more files file1, file2,&#8230; with one file X, and
1850 shows how X differs from each of fileN. One column for each of
1851 fileN is prepended to the output line to note how X&#8217;s line is
1852 different from it.</p></div>
1853 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1854 fileN but it does not appear in the result. A <tt>+</tt> character
1855 in the column N means that the line appears in the result,
1856 and fileN does not have that line (in other words, the line was
1857 added, from the point of view of that parent).</p></div>
1858 <div class="paragraph"><p>In the above example output, the function signature was changed
1859 from both files (hence two <tt>-</tt> removals from both file1 and
1860 file2, plus <tt>++</tt> to mean one line that was added does not appear
1861 in either file1 nor file2). Also eight other lines are the same
1862 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1863 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1864 merge commit with the merge result (i.e. file1..fileN are the
1865 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1866 two unresolved merge parents with the working tree file
1867 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1868 "their version").</p></div>
1869 </div>
1870 <h2 id="_other_diff_formats">other diff formats</h2>
1871 <div class="sectionbody">
1872 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1873 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1874 output. These options can be combined with other options, such as
1875 <tt>-p</tt>, and are meant for human consumption.</p></div>
1876 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1877 formats the pathnames compactly by combining common prefix and suffix of
1878 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1879 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1880 <div class="listingblock">
1881 <div class="content">
1882 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1883 </div></div>
1884 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1885 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1886 like this:</p></div>
1887 <div class="listingblock">
1888 <div class="content">
1889 <pre><tt>1 2 README
1890 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1891 </div></div>
1892 <div class="paragraph"><p>That is, from left to right:</p></div>
1893 <div class="olist arabic"><ol class="arabic">
1894 <li>
1896 the number of added lines;
1897 </p>
1898 </li>
1899 <li>
1901 a tab;
1902 </p>
1903 </li>
1904 <li>
1906 the number of deleted lines;
1907 </p>
1908 </li>
1909 <li>
1911 a tab;
1912 </p>
1913 </li>
1914 <li>
1916 pathname (possibly with rename/copy information);
1917 </p>
1918 </li>
1919 <li>
1921 a newline.
1922 </p>
1923 </li>
1924 </ol></div>
1925 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1926 <div class="listingblock">
1927 <div class="content">
1928 <pre><tt>1 2 README NUL
1929 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1930 </div></div>
1931 <div class="paragraph"><p>That is:</p></div>
1932 <div class="olist arabic"><ol class="arabic">
1933 <li>
1935 the number of added lines;
1936 </p>
1937 </li>
1938 <li>
1940 a tab;
1941 </p>
1942 </li>
1943 <li>
1945 the number of deleted lines;
1946 </p>
1947 </li>
1948 <li>
1950 a tab;
1951 </p>
1952 </li>
1953 <li>
1955 a NUL (only exists if renamed/copied);
1956 </p>
1957 </li>
1958 <li>
1960 pathname in preimage;
1961 </p>
1962 </li>
1963 <li>
1965 a NUL (only exists if renamed/copied);
1966 </p>
1967 </li>
1968 <li>
1970 pathname in postimage (only exists if renamed/copied);
1971 </p>
1972 </li>
1973 <li>
1975 a NUL.
1976 </p>
1977 </li>
1978 </ol></div>
1979 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1980 scripts that read the output to tell if the current record being read is
1981 a single-path record or a rename/copy record without reading ahead.
1982 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1983 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1984 </div>
1985 <h2 id="_examples">EXAMPLES</h2>
1986 <div class="sectionbody">
1987 <div class="dlist"><dl>
1988 <dt class="hdlist1">
1989 Various ways to check your working tree
1990 </dt>
1991 <dd>
1992 <div class="listingblock">
1993 <div class="content">
1994 <pre><tt>$ git diff <b>&lt;1&gt;</b>
1995 $ git diff --cached <b>&lt;2&gt;</b>
1996 $ git diff HEAD <b>&lt;3&gt;</b></tt></pre>
1997 </div></div>
1998 <div class="colist arabic"><ol>
1999 <li>
2001 Changes in the working tree not yet staged for the next commit.
2002 </p>
2003 </li>
2004 <li>
2006 Changes between the index and your last commit; what you
2007 would be committing if you run "git commit" without "-a" option.
2008 </p>
2009 </li>
2010 <li>
2012 Changes in the working tree since your last commit; what you
2013 would be committing if you run "git commit -a"
2014 </p>
2015 </li>
2016 </ol></div>
2017 </dd>
2018 <dt class="hdlist1">
2019 Comparing with arbitrary commits
2020 </dt>
2021 <dd>
2022 <div class="listingblock">
2023 <div class="content">
2024 <pre><tt>$ git diff test <b>&lt;1&gt;</b>
2025 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
2026 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></tt></pre>
2027 </div></div>
2028 <div class="colist arabic"><ol>
2029 <li>
2031 Instead of using the tip of the current branch, compare with the
2032 tip of "test" branch.
2033 </p>
2034 </li>
2035 <li>
2037 Instead of comparing with the tip of "test" branch, compare with
2038 the tip of the current branch, but limit the comparison to the
2039 file "test".
2040 </p>
2041 </li>
2042 <li>
2044 Compare the version before the last commit and the last commit.
2045 </p>
2046 </li>
2047 </ol></div>
2048 </dd>
2049 <dt class="hdlist1">
2050 Comparing branches
2051 </dt>
2052 <dd>
2053 <div class="listingblock">
2054 <div class="content">
2055 <pre><tt>$ git diff topic master <b>&lt;1&gt;</b>
2056 $ git diff topic..master <b>&lt;2&gt;</b>
2057 $ git diff topic...master <b>&lt;3&gt;</b></tt></pre>
2058 </div></div>
2059 <div class="colist arabic"><ol>
2060 <li>
2062 Changes between the tips of the topic and the master branches.
2063 </p>
2064 </li>
2065 <li>
2067 Same as above.
2068 </p>
2069 </li>
2070 <li>
2072 Changes that occurred on the master branch since when the topic
2073 branch was started off it.
2074 </p>
2075 </li>
2076 </ol></div>
2077 </dd>
2078 <dt class="hdlist1">
2079 Limiting the diff output
2080 </dt>
2081 <dd>
2082 <div class="listingblock">
2083 <div class="content">
2084 <pre><tt>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
2085 $ git diff --name-status <b>&lt;2&gt;</b>
2086 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></tt></pre>
2087 </div></div>
2088 <div class="colist arabic"><ol>
2089 <li>
2091 Show only modification, rename and copy, but not addition
2092 nor deletion.
2093 </p>
2094 </li>
2095 <li>
2097 Show only names and the nature of change, but not actual
2098 diff output.
2099 </p>
2100 </li>
2101 <li>
2103 Limit diff output to named subtrees.
2104 </p>
2105 </li>
2106 </ol></div>
2107 </dd>
2108 <dt class="hdlist1">
2109 Munging the diff output
2110 </dt>
2111 <dd>
2112 <div class="listingblock">
2113 <div class="content">
2114 <pre><tt>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
2115 $ git diff -R <b>&lt;2&gt;</b></tt></pre>
2116 </div></div>
2117 <div class="colist arabic"><ol>
2118 <li>
2120 Spend extra cycles to find renames, copies and complete
2121 rewrites (very expensive).
2122 </p>
2123 </li>
2124 <li>
2126 Output diff in reverse.
2127 </p>
2128 </li>
2129 </ol></div>
2130 </dd>
2131 </dl></div>
2132 </div>
2133 <h2 id="_see_also">SEE ALSO</h2>
2134 <div class="sectionbody">
2135 <div class="paragraph"><p>diff(1),
2136 <a href="git-difftool.html">git-difftool(1)</a>,
2137 <a href="git-log.html">git-log(1)</a>,
2138 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
2139 <a href="git-format-patch.html">git-format-patch(1)</a>,
2140 <a href="git-apply.html">git-apply(1)</a></p></div>
2141 </div>
2142 <h2 id="_git">GIT</h2>
2143 <div class="sectionbody">
2144 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2145 </div>
2146 </div>
2147 <div id="footnotes"><hr /></div>
2148 <div id="footer">
2149 <div id="footer-text">
2150 Last updated 2011-09-21 23:01:14 PDT
2151 </div>
2152 </div>
2153 </body>
2154 </html>