Autogenerated HTML docs for v1.7.7-325-g05f6ed
[git/jnareb-git.git] / git-diff-index.html
blob0c941c26552f2908ab0b83b0f293288852c5c2b3
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-index(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-index(1) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>git-diff-index -
578 Compares content and mode of blobs between the index and repository
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-index</em> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</div>
587 <div class="verseblock-attribution">
588 </div></div>
589 </div>
590 <h2 id="_description">DESCRIPTION</h2>
591 <div class="sectionbody">
592 <div class="paragraph"><p>Compares the content and mode of the blobs found via a tree
593 object with the content of the current index and, optionally
594 ignoring the stat state of the file on disk. When paths are
595 specified, compares only those named paths. Otherwise all
596 entries in the index are compared.</p></div>
597 </div>
598 <h2 id="_options">OPTIONS</h2>
599 <div class="sectionbody">
600 <div class="dlist"><dl>
601 <dt class="hdlist1">
603 </dt>
604 <dt class="hdlist1">
606 </dt>
607 <dt class="hdlist1">
608 --patch
609 </dt>
610 <dd>
612 Generate patch (see section on generating patches).
614 </p>
615 </dd>
616 <dt class="hdlist1">
617 -U&lt;n&gt;
618 </dt>
619 <dt class="hdlist1">
620 --unified=&lt;n&gt;
621 </dt>
622 <dd>
624 Generate diffs with &lt;n&gt; lines of context instead of
625 the usual three.
626 Implies <tt>-p</tt>.
627 </p>
628 </dd>
629 <dt class="hdlist1">
630 --raw
631 </dt>
632 <dd>
634 Generate the raw format.
635 This is the default.
636 </p>
637 </dd>
638 <dt class="hdlist1">
639 --patch-with-raw
640 </dt>
641 <dd>
643 Synonym for <tt>-p --raw</tt>.
644 </p>
645 </dd>
646 <dt class="hdlist1">
647 --minimal
648 </dt>
649 <dd>
651 Spend extra time to make sure the smallest possible
652 diff is produced.
653 </p>
654 </dd>
655 <dt class="hdlist1">
656 --patience
657 </dt>
658 <dd>
660 Generate a diff using the "patience diff" algorithm.
661 </p>
662 </dd>
663 <dt class="hdlist1">
664 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
665 </dt>
666 <dd>
668 Generate a diffstat. You can override the default
669 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
670 The width of the filename part can be controlled by
671 giving another width to it separated by a comma.
672 By giving a third parameter <tt>&lt;count&gt;</tt>, you can limit the
673 output to the first <tt>&lt;count&gt;</tt> lines, followed by
674 <tt>&#8230;</tt> if there are more.
675 </p>
676 <div class="paragraph"><p>These parameters can also be set individually with <tt>--stat-width=&lt;width&gt;</tt>,
677 <tt>--stat-name-width=&lt;name-width&gt;</tt> and <tt>--stat-count=&lt;count&gt;</tt>.</p></div>
678 </dd>
679 <dt class="hdlist1">
680 --numstat
681 </dt>
682 <dd>
684 Similar to <tt>--stat</tt>, but shows number of added and
685 deleted lines in decimal notation and pathname without
686 abbreviation, to make it more machine friendly. For
687 binary files, outputs two <tt>-</tt> instead of saying
688 <tt>0 0</tt>.
689 </p>
690 </dd>
691 <dt class="hdlist1">
692 --shortstat
693 </dt>
694 <dd>
696 Output only the last line of the <tt>--stat</tt> format containing total
697 number of modified files, as well as number of added and deleted
698 lines.
699 </p>
700 </dd>
701 <dt class="hdlist1">
702 --dirstat[=&lt;param1,param2,&#8230;&gt;]
703 </dt>
704 <dd>
706 Output the distribution of relative amount of changes for each
707 sub-directory. The behavior of <tt>--dirstat</tt> can be customized by
708 passing it a comma separated list of parameters.
709 The defaults are controlled by the <tt>diff.dirstat</tt> configuration
710 variable (see <a href="git-config.html">git-config(1)</a>).
711 The following parameters are available:
712 </p>
713 <div class="dlist"><dl>
714 <dt class="hdlist1">
715 <tt>changes</tt>
716 </dt>
717 <dd>
719 Compute the dirstat numbers by counting the lines that have been
720 removed from the source, or added to the destination. This ignores
721 the amount of pure code movements within a file. In other words,
722 rearranging lines in a file is not counted as much as other changes.
723 This is the default behavior when no parameter is given.
724 </p>
725 </dd>
726 <dt class="hdlist1">
727 <tt>lines</tt>
728 </dt>
729 <dd>
731 Compute the dirstat numbers by doing the regular line-based diff
732 analysis, and summing the removed/added line counts. (For binary
733 files, count 64-byte chunks instead, since binary files have no
734 natural concept of lines). This is a more expensive <tt>--dirstat</tt>
735 behavior than the <tt>changes</tt> behavior, but it does count rearranged
736 lines within a file as much as other changes. The resulting output
737 is consistent with what you get from the other <tt>--*stat</tt> options.
738 </p>
739 </dd>
740 <dt class="hdlist1">
741 <tt>files</tt>
742 </dt>
743 <dd>
745 Compute the dirstat numbers by counting the number of files changed.
746 Each changed file counts equally in the dirstat analysis. This is
747 the computationally cheapest <tt>--dirstat</tt> behavior, since it does
748 not have to look at the file contents at all.
749 </p>
750 </dd>
751 <dt class="hdlist1">
752 <tt>cumulative</tt>
753 </dt>
754 <dd>
756 Count changes in a child directory for the parent directory as well.
757 Note that when using <tt>cumulative</tt>, the sum of the percentages
758 reported may exceed 100%. The default (non-cumulative) behavior can
759 be specified with the <tt>noncumulative</tt> parameter.
760 </p>
761 </dd>
762 <dt class="hdlist1">
763 &lt;limit&gt;
764 </dt>
765 <dd>
767 An integer parameter specifies a cut-off percent (3% by default).
768 Directories contributing less than this percentage of the changes
769 are not shown in the output.
770 </p>
771 </dd>
772 </dl></div>
773 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
774 directories with less than 10% of the total amount of changed files,
775 and accumulating child directory counts in the parent directories:
776 <tt>--dirstat=files,10,cumulative</tt>.</p></div>
777 </dd>
778 <dt class="hdlist1">
779 --summary
780 </dt>
781 <dd>
783 Output a condensed summary of extended header information
784 such as creations, renames and mode changes.
785 </p>
786 </dd>
787 <dt class="hdlist1">
788 --patch-with-stat
789 </dt>
790 <dd>
792 Synonym for <tt>-p --stat</tt>.
793 </p>
794 </dd>
795 <dt class="hdlist1">
797 </dt>
798 <dd>
800 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
801 given, do not munge pathnames and use NULs as output field terminators.
802 </p>
803 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
804 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
805 respectively, and the pathname will be enclosed in double quotes if
806 any of those replacements occurred.</p></div>
807 </dd>
808 <dt class="hdlist1">
809 --name-only
810 </dt>
811 <dd>
813 Show only names of changed files.
814 </p>
815 </dd>
816 <dt class="hdlist1">
817 --name-status
818 </dt>
819 <dd>
821 Show only names and status of changed files. See the description
822 of the <tt>--diff-filter</tt> option on what the status letters mean.
823 </p>
824 </dd>
825 <dt class="hdlist1">
826 --submodule[=&lt;format&gt;]
827 </dt>
828 <dd>
830 Chose the output format for submodule differences. &lt;format&gt; can be one of
831 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
832 is used when this option is not given. <em>log</em> is the default value for this
833 option and lists the commits in that commit range like the <em>summary</em>
834 option of <a href="git-submodule.html">git-submodule(1)</a> does.
835 </p>
836 </dd>
837 <dt class="hdlist1">
838 --color[=&lt;when&gt;]
839 </dt>
840 <dd>
842 Show colored diff.
843 The value must be <tt>always</tt> (the default for <tt>&lt;when&gt;</tt>), <tt>never</tt>, or <tt>auto</tt>.
844 The default value is <tt>never</tt>.
845 </p>
846 </dd>
847 <dt class="hdlist1">
848 --no-color
849 </dt>
850 <dd>
852 Turn off colored diff.
853 It is the same as <tt>--color=never</tt>.
854 </p>
855 </dd>
856 <dt class="hdlist1">
857 --word-diff[=&lt;mode&gt;]
858 </dt>
859 <dd>
861 Show a word diff, using the &lt;mode&gt; to delimit changed words.
862 By default, words are delimited by whitespace; see
863 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
864 must be one of:
865 </p>
866 <div class="dlist"><dl>
867 <dt class="hdlist1">
868 color
869 </dt>
870 <dd>
872 Highlight changed words using only colors. Implies <tt>--color</tt>.
873 </p>
874 </dd>
875 <dt class="hdlist1">
876 plain
877 </dt>
878 <dd>
880 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
881 attempts to escape the delimiters if they appear in the input,
882 so the output may be ambiguous.
883 </p>
884 </dd>
885 <dt class="hdlist1">
886 porcelain
887 </dt>
888 <dd>
890 Use a special line-based format intended for script
891 consumption. Added/removed/unchanged runs are printed in the
892 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
893 character at the beginning of the line and extending to the
894 end of the line. Newlines in the input are represented by a
895 tilde <tt>~</tt> on a line of its own.
896 </p>
897 </dd>
898 <dt class="hdlist1">
899 none
900 </dt>
901 <dd>
903 Disable word diff again.
904 </p>
905 </dd>
906 </dl></div>
907 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
908 highlight the changed parts in all modes if enabled.</p></div>
909 </dd>
910 <dt class="hdlist1">
911 --word-diff-regex=&lt;regex&gt;
912 </dt>
913 <dd>
915 Use &lt;regex&gt; to decide what a word is, instead of considering
916 runs of non-whitespace to be a word. Also implies
917 <tt>--word-diff</tt> unless it was already enabled.
918 </p>
919 <div class="paragraph"><p>Every non-overlapping match of the
920 &lt;regex&gt; is considered a word. Anything between these matches is
921 considered whitespace and ignored(!) for the purposes of finding
922 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
923 expression to make sure that it matches all non-whitespace characters.
924 A match that contains a newline is silently truncated(!) at the
925 newline.</p></div>
926 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
927 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
928 overrides any diff driver or configuration setting. Diff drivers
929 override configuration settings.</p></div>
930 </dd>
931 <dt class="hdlist1">
932 --color-words[=&lt;regex&gt;]
933 </dt>
934 <dd>
936 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
937 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
938 </p>
939 </dd>
940 <dt class="hdlist1">
941 --no-renames
942 </dt>
943 <dd>
945 Turn off rename detection, even when the configuration
946 file gives the default to do so.
947 </p>
948 </dd>
949 <dt class="hdlist1">
950 --check
951 </dt>
952 <dd>
954 Warn if changes introduce whitespace errors. What are
955 considered whitespace errors is controlled by <tt>core.whitespace</tt>
956 configuration. By default, trailing whitespaces (including
957 lines that solely consist of whitespaces) and a space character
958 that is immediately followed by a tab character inside the
959 initial indent of the line are considered whitespace errors.
960 Exits with non-zero status if problems are found. Not compatible
961 with --exit-code.
962 </p>
963 </dd>
964 <dt class="hdlist1">
965 --full-index
966 </dt>
967 <dd>
969 Instead of the first handful of characters, show the full
970 pre- and post-image blob object names on the "index"
971 line when generating patch format output.
972 </p>
973 </dd>
974 <dt class="hdlist1">
975 --binary
976 </dt>
977 <dd>
979 In addition to <tt>--full-index</tt>, output a binary diff that
980 can be applied with <tt>git-apply</tt>.
981 </p>
982 </dd>
983 <dt class="hdlist1">
984 --abbrev[=&lt;n&gt;]
985 </dt>
986 <dd>
988 Instead of showing the full 40-byte hexadecimal object
989 name in diff-raw format output and diff-tree header
990 lines, show only a partial prefix. This is
991 independent of the <tt>--full-index</tt> option above, which controls
992 the diff-patch output format. Non default number of
993 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
994 </p>
995 </dd>
996 <dt class="hdlist1">
997 -B[&lt;n&gt;][/&lt;m&gt;]
998 </dt>
999 <dt class="hdlist1">
1000 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
1001 </dt>
1002 <dd>
1004 Break complete rewrite changes into pairs of delete and
1005 create. This serves two purposes:
1006 </p>
1007 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1008 not as a series of deletion and insertion mixed together with a very
1009 few lines that happen to match textually as the context, but as a
1010 single deletion of everything old followed by a single insertion of
1011 everything new, and the number <tt>m</tt> controls this aspect of the -B
1012 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
1013 original should remain in the result for git to consider it a total
1014 rewrite (i.e. otherwise the resulting patch will be a series of
1015 deletion and insertion mixed together with context lines).</p></div>
1016 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1017 source of a rename (usually -M only considers a file that disappeared
1018 as the source of a rename), and the number <tt>n</tt> controls this aspect of
1019 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
1020 addition and deletion compared to 20% or more of the file&#8217;s size are
1021 eligible for being picked up as a possible source of a rename to
1022 another file.</p></div>
1023 </dd>
1024 <dt class="hdlist1">
1025 -M[&lt;n&gt;]
1026 </dt>
1027 <dt class="hdlist1">
1028 --find-renames[=&lt;n&gt;]
1029 </dt>
1030 <dd>
1032 Detect renames.
1033 If <tt>n</tt> is specified, it is a threshold on the similarity
1034 index (i.e. amount of addition/deletions compared to the
1035 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
1036 delete/add pair to be a rename if more than 90% of the file
1037 hasn&#8217;t changed.
1038 </p>
1039 </dd>
1040 <dt class="hdlist1">
1041 -C[&lt;n&gt;]
1042 </dt>
1043 <dt class="hdlist1">
1044 --find-copies[=&lt;n&gt;]
1045 </dt>
1046 <dd>
1048 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
1049 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
1050 </p>
1051 </dd>
1052 <dt class="hdlist1">
1053 --find-copies-harder
1054 </dt>
1055 <dd>
1057 For performance reasons, by default, <tt>-C</tt> option finds copies only
1058 if the original file of the copy was modified in the same
1059 changeset. This flag makes the command
1060 inspect unmodified files as candidates for the source of
1061 copy. This is a very expensive operation for large
1062 projects, so use it with caution. Giving more than one
1063 <tt>-C</tt> option has the same effect.
1064 </p>
1065 </dd>
1066 <dt class="hdlist1">
1068 </dt>
1069 <dt class="hdlist1">
1070 --irreversible-delete
1071 </dt>
1072 <dd>
1074 Omit the preimage for deletes, i.e. print only the header but not
1075 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
1076 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
1077 solely for people who want to just concentrate on reviewing the
1078 text after the change. In addition, the output obviously lack
1079 enough information to apply such a patch in reverse, even manually,
1080 hence the name of the option.
1081 </p>
1082 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
1083 of a delete/create pair.</p></div>
1084 </dd>
1085 <dt class="hdlist1">
1086 -l&lt;num&gt;
1087 </dt>
1088 <dd>
1090 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
1091 is the number of potential rename/copy targets. This
1092 option prevents rename/copy detection from running if
1093 the number of rename/copy targets exceeds the specified
1094 number.
1095 </p>
1096 </dd>
1097 <dt class="hdlist1">
1098 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1099 </dt>
1100 <dd>
1102 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
1103 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
1104 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
1105 are Unmerged (<tt>U</tt>), are
1106 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
1107 Any combination of the filter characters (including none) can be used.
1108 When <tt>*</tt> (All-or-none) is added to the combination, all
1109 paths are selected if there is any file that matches
1110 other criteria in the comparison; if there is no file
1111 that matches other criteria, nothing is selected.
1112 </p>
1113 </dd>
1114 <dt class="hdlist1">
1115 -S&lt;string&gt;
1116 </dt>
1117 <dd>
1119 Look for differences that introduce or remove an instance of
1120 &lt;string&gt;. Note that this is different than the string simply
1121 appearing in diff output; see the <em>pickaxe</em> entry in
1122 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
1123 </p>
1124 </dd>
1125 <dt class="hdlist1">
1126 -G&lt;regex&gt;
1127 </dt>
1128 <dd>
1130 Look for differences whose added or removed line matches
1131 the given &lt;regex&gt;.
1132 </p>
1133 </dd>
1134 <dt class="hdlist1">
1135 --pickaxe-all
1136 </dt>
1137 <dd>
1139 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
1140 changeset, not just the files that contain the change
1141 in &lt;string&gt;.
1142 </p>
1143 </dd>
1144 <dt class="hdlist1">
1145 --pickaxe-regex
1146 </dt>
1147 <dd>
1149 Make the &lt;string&gt; not a plain string but an extended POSIX
1150 regex to match.
1151 </p>
1152 </dd>
1153 <dt class="hdlist1">
1154 -O&lt;orderfile&gt;
1155 </dt>
1156 <dd>
1158 Output the patch in the order specified in the
1159 &lt;orderfile&gt;, which has one shell glob pattern per line.
1160 </p>
1161 </dd>
1162 <dt class="hdlist1">
1164 </dt>
1165 <dd>
1167 Swap two inputs; that is, show differences from index or
1168 on-disk file to tree contents.
1169 </p>
1170 </dd>
1171 <dt class="hdlist1">
1172 --relative[=&lt;path&gt;]
1173 </dt>
1174 <dd>
1176 When run from a subdirectory of the project, it can be
1177 told to exclude changes outside the directory and show
1178 pathnames relative to it with this option. When you are
1179 not in a subdirectory (e.g. in a bare repository), you
1180 can name which subdirectory to make the output relative
1181 to by giving a &lt;path&gt; as an argument.
1182 </p>
1183 </dd>
1184 <dt class="hdlist1">
1186 </dt>
1187 <dt class="hdlist1">
1188 --text
1189 </dt>
1190 <dd>
1192 Treat all files as text.
1193 </p>
1194 </dd>
1195 <dt class="hdlist1">
1196 --ignore-space-at-eol
1197 </dt>
1198 <dd>
1200 Ignore changes in whitespace at EOL.
1201 </p>
1202 </dd>
1203 <dt class="hdlist1">
1205 </dt>
1206 <dt class="hdlist1">
1207 --ignore-space-change
1208 </dt>
1209 <dd>
1211 Ignore changes in amount of whitespace. This ignores whitespace
1212 at line end, and considers all other sequences of one or
1213 more whitespace characters to be equivalent.
1214 </p>
1215 </dd>
1216 <dt class="hdlist1">
1218 </dt>
1219 <dt class="hdlist1">
1220 --ignore-all-space
1221 </dt>
1222 <dd>
1224 Ignore whitespace when comparing lines. This ignores
1225 differences even if one line has whitespace where the other
1226 line has none.
1227 </p>
1228 </dd>
1229 <dt class="hdlist1">
1230 --inter-hunk-context=&lt;lines&gt;
1231 </dt>
1232 <dd>
1234 Show the context between diff hunks, up to the specified number
1235 of lines, thereby fusing hunks that are close to each other.
1236 </p>
1237 </dd>
1238 <dt class="hdlist1">
1239 --exit-code
1240 </dt>
1241 <dd>
1243 Make the program exit with codes similar to diff(1).
1244 That is, it exits with 1 if there were differences and
1245 0 means no differences.
1246 </p>
1247 </dd>
1248 <dt class="hdlist1">
1249 --quiet
1250 </dt>
1251 <dd>
1253 Disable all output of the program. Implies <tt>--exit-code</tt>.
1254 </p>
1255 </dd>
1256 <dt class="hdlist1">
1257 --ext-diff
1258 </dt>
1259 <dd>
1261 Allow an external diff helper to be executed. If you set an
1262 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1263 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1264 </p>
1265 </dd>
1266 <dt class="hdlist1">
1267 --no-ext-diff
1268 </dt>
1269 <dd>
1271 Disallow external diff drivers.
1272 </p>
1273 </dd>
1274 <dt class="hdlist1">
1275 --textconv
1276 </dt>
1277 <dt class="hdlist1">
1278 --no-textconv
1279 </dt>
1280 <dd>
1282 Allow (or disallow) external text conversion filters to be run
1283 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1284 details. Because textconv filters are typically a one-way
1285 conversion, the resulting diff is suitable for human
1286 consumption, but cannot be applied. For this reason, textconv
1287 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1288 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1289 diff plumbing commands.
1290 </p>
1291 </dd>
1292 <dt class="hdlist1">
1293 --ignore-submodules[=&lt;when&gt;]
1294 </dt>
1295 <dd>
1297 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1298 either "none", "untracked", "dirty" or "all", which is the default
1299 Using "none" will consider the submodule modified when it either contains
1300 untracked or modified files or its HEAD differs from the commit recorded
1301 in the superproject and can be used to override any settings of the
1302 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1303 "untracked" is used submodules are not considered dirty when they only
1304 contain untracked content (but they are still scanned for modified
1305 content). Using "dirty" ignores all changes to the work tree of submodules,
1306 only changes to the commits stored in the superproject are shown (this was
1307 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1308 </p>
1309 </dd>
1310 <dt class="hdlist1">
1311 --src-prefix=&lt;prefix&gt;
1312 </dt>
1313 <dd>
1315 Show the given source prefix instead of "a/".
1316 </p>
1317 </dd>
1318 <dt class="hdlist1">
1319 --dst-prefix=&lt;prefix&gt;
1320 </dt>
1321 <dd>
1323 Show the given destination prefix instead of "b/".
1324 </p>
1325 </dd>
1326 <dt class="hdlist1">
1327 --no-prefix
1328 </dt>
1329 <dd>
1331 Do not show any source or destination prefix.
1332 </p>
1333 </dd>
1334 </dl></div>
1335 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1336 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1337 <div class="dlist"><dl>
1338 <dt class="hdlist1">
1339 &lt;tree-ish&gt;
1340 </dt>
1341 <dd>
1343 The id of a tree object to diff against.
1344 </p>
1345 </dd>
1346 <dt class="hdlist1">
1347 --cached
1348 </dt>
1349 <dd>
1351 do not consider the on-disk file at all
1352 </p>
1353 </dd>
1354 <dt class="hdlist1">
1356 </dt>
1357 <dd>
1359 By default, files recorded in the index but not checked
1360 out are reported as deleted. This flag makes
1361 <em>git diff-index</em> say that all non-checked-out files are up
1362 to date.
1363 </p>
1364 </dd>
1365 </dl></div>
1366 </div>
1367 <h2 id="_raw_output_format">Raw output format</h2>
1368 <div class="sectionbody">
1369 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1370 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1371 <div class="paragraph"><p>These commands all compare two sets of things; what is
1372 compared differs:</p></div>
1373 <div class="dlist"><dl>
1374 <dt class="hdlist1">
1375 git-diff-index &lt;tree-ish&gt;
1376 </dt>
1377 <dd>
1379 compares the &lt;tree-ish&gt; and the files on the filesystem.
1380 </p>
1381 </dd>
1382 <dt class="hdlist1">
1383 git-diff-index --cached &lt;tree-ish&gt;
1384 </dt>
1385 <dd>
1387 compares the &lt;tree-ish&gt; and the index.
1388 </p>
1389 </dd>
1390 <dt class="hdlist1">
1391 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1392 </dt>
1393 <dd>
1395 compares the trees named by the two arguments.
1396 </p>
1397 </dd>
1398 <dt class="hdlist1">
1399 git-diff-files [&lt;pattern&gt;&#8230;]
1400 </dt>
1401 <dd>
1403 compares the index and the files on the filesystem.
1404 </p>
1405 </dd>
1406 </dl></div>
1407 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1408 what is being compared. After that, all the commands print one output
1409 line per changed file.</p></div>
1410 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1411 <div class="listingblock">
1412 <div class="content">
1413 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1414 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1415 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1416 create :000000 100644 0000000... 1234567... A file4
1417 delete :100644 000000 1234567... 0000000... D file5
1418 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1419 </div></div>
1420 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1421 <div class="olist arabic"><ol class="arabic">
1422 <li>
1424 a colon.
1425 </p>
1426 </li>
1427 <li>
1429 mode for "src"; 000000 if creation or unmerged.
1430 </p>
1431 </li>
1432 <li>
1434 a space.
1435 </p>
1436 </li>
1437 <li>
1439 mode for "dst"; 000000 if deletion or unmerged.
1440 </p>
1441 </li>
1442 <li>
1444 a space.
1445 </p>
1446 </li>
1447 <li>
1449 sha1 for "src"; 0{40} if creation or unmerged.
1450 </p>
1451 </li>
1452 <li>
1454 a space.
1455 </p>
1456 </li>
1457 <li>
1459 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1460 </p>
1461 </li>
1462 <li>
1464 a space.
1465 </p>
1466 </li>
1467 <li>
1469 status, followed by optional "score" number.
1470 </p>
1471 </li>
1472 <li>
1474 a tab or a NUL when <em>-z</em> option is used.
1475 </p>
1476 </li>
1477 <li>
1479 path for "src"
1480 </p>
1481 </li>
1482 <li>
1484 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1485 </p>
1486 </li>
1487 <li>
1489 path for "dst"; only exists for C or R.
1490 </p>
1491 </li>
1492 <li>
1494 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1495 </p>
1496 </li>
1497 </ol></div>
1498 <div class="paragraph"><p>Possible status letters are:</p></div>
1499 <div class="ulist"><ul>
1500 <li>
1502 A: addition of a file
1503 </p>
1504 </li>
1505 <li>
1507 C: copy of a file into a new one
1508 </p>
1509 </li>
1510 <li>
1512 D: deletion of a file
1513 </p>
1514 </li>
1515 <li>
1517 M: modification of the contents or mode of a file
1518 </p>
1519 </li>
1520 <li>
1522 R: renaming of a file
1523 </p>
1524 </li>
1525 <li>
1527 T: change in the type of the file
1528 </p>
1529 </li>
1530 <li>
1532 U: file is unmerged (you must complete the merge before it can
1533 be committed)
1534 </p>
1535 </li>
1536 <li>
1538 X: "unknown" change type (most probably a bug, please report it)
1539 </p>
1540 </li>
1541 </ul></div>
1542 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1543 percentage of similarity between the source and target of the move or
1544 copy), and are the only ones to be so.</p></div>
1545 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1546 and it is out of sync with the index.</p></div>
1547 <div class="paragraph"><p>Example:</p></div>
1548 <div class="listingblock">
1549 <div class="content">
1550 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1551 </div></div>
1552 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1553 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1554 respectively.</p></div>
1555 </div>
1556 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1557 <div class="sectionbody">
1558 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1559 can take <em>-c</em> or <em>--cc</em> option
1560 to generate diff output also for merge commits. The output differs
1561 from the format described above in the following way:</p></div>
1562 <div class="olist arabic"><ol class="arabic">
1563 <li>
1565 there is a colon for each parent
1566 </p>
1567 </li>
1568 <li>
1570 there are more "src" modes and "src" sha1
1571 </p>
1572 </li>
1573 <li>
1575 status is concatenated status characters for each parent
1576 </p>
1577 </li>
1578 <li>
1580 no optional "score" number
1581 </p>
1582 </li>
1583 <li>
1585 single path, only for "dst"
1586 </p>
1587 </li>
1588 </ol></div>
1589 <div class="paragraph"><p>Example:</p></div>
1590 <div class="listingblock">
1591 <div class="content">
1592 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1593 </div></div>
1594 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1595 all parents.</p></div>
1596 </div>
1597 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1598 <div class="sectionbody">
1599 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1600 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1601 "git log" with the "-p" option, they
1602 do not produce the output described above; instead they produce a
1603 patch file. You can customize the creation of such patches via the
1604 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1605 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1606 diff format:</p></div>
1607 <div class="olist arabic"><ol class="arabic">
1608 <li>
1610 It is preceded with a "git diff" header that looks like this:
1611 </p>
1612 <div class="literalblock">
1613 <div class="content">
1614 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1615 </div></div>
1616 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1617 involved. Especially, even for a creation or a deletion,
1618 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1619 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1620 name of the source file of the rename/copy and the name of
1621 the file that rename/copy produces, respectively.</p></div>
1622 </li>
1623 <li>
1625 It is followed by one or more extended header lines:
1626 </p>
1627 <div class="literalblock">
1628 <div class="content">
1629 <pre><tt>old mode &lt;mode&gt;
1630 new mode &lt;mode&gt;
1631 deleted file mode &lt;mode&gt;
1632 new file mode &lt;mode&gt;
1633 copy from &lt;path&gt;
1634 copy to &lt;path&gt;
1635 rename from &lt;path&gt;
1636 rename to &lt;path&gt;
1637 similarity index &lt;number&gt;
1638 dissimilarity index &lt;number&gt;
1639 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1640 </div></div>
1641 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1642 and file permission bits.</p></div>
1643 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1644 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1645 the dissimilarity index is the percentage of changed lines. It
1646 is a rounded down integer, followed by a percent sign. The
1647 similarity index value of 100% is thus reserved for two equal
1648 files, while 100% dissimilarity means that no line from the old
1649 file made it into the new one.</p></div>
1650 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1651 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1652 separate lines indicate the old and the new mode.</p></div>
1653 </li>
1654 <li>
1656 TAB, LF, double quote and backslash characters in pathnames
1657 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1658 If there is need for such substitution then the whole
1659 pathname is put in double quotes.
1660 </p>
1661 </li>
1662 <li>
1664 All the <tt>file1</tt> files in the output refer to files before the
1665 commit, and all the <tt>file2</tt> files refer to files after the commit.
1666 It is incorrect to apply each change to each file sequentially. For
1667 example, this patch will swap a and b:
1668 </p>
1669 <div class="literalblock">
1670 <div class="content">
1671 <pre><tt>diff --git a/a b/b
1672 rename from a
1673 rename to b
1674 diff --git a/b b/a
1675 rename from b
1676 rename to a</tt></pre>
1677 </div></div>
1678 </li>
1679 </ol></div>
1680 </div>
1681 <h2 id="_combined_diff_format">combined diff format</h2>
1682 <div class="sectionbody">
1683 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1684 produce a <em>combined diff</em> when showing a merge. This is the default
1685 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1686 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1687 of these commands to force generation of diffs with individual parents
1688 of a merge.</p></div>
1689 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1690 <div class="listingblock">
1691 <div class="content">
1692 <pre><tt>diff --combined describe.c
1693 index fabadb8,cc95eb0..4866510
1694 --- a/describe.c
1695 +++ b/describe.c
1696 @@@ -98,20 -98,12 +98,20 @@@
1697 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1700 - static void describe(char *arg)
1701 -static void describe(struct commit *cmit, int last_one)
1702 ++static void describe(char *arg, int last_one)
1704 + unsigned char sha1[20];
1705 + struct commit *cmit;
1706 struct commit_list *list;
1707 static int initialized = 0;
1708 struct commit_name *n;
1710 + if (get_sha1(arg, sha1) &lt; 0)
1711 + usage(describe_usage);
1712 + cmit = lookup_commit_reference(sha1);
1713 + if (!cmit)
1714 + usage(describe_usage);
1716 if (!initialized) {
1717 initialized = 1;
1718 for_each_ref(get_name);</tt></pre>
1719 </div></div>
1720 <div class="olist arabic"><ol class="arabic">
1721 <li>
1723 It is preceded with a "git diff" header, that looks like
1724 this (when <em>-c</em> option is used):
1725 </p>
1726 <div class="literalblock">
1727 <div class="content">
1728 <pre><tt>diff --combined file</tt></pre>
1729 </div></div>
1730 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1731 <div class="literalblock">
1732 <div class="content">
1733 <pre><tt>diff --cc file</tt></pre>
1734 </div></div>
1735 </li>
1736 <li>
1738 It is followed by one or more extended header lines
1739 (this example shows a merge with two parents):
1740 </p>
1741 <div class="literalblock">
1742 <div class="content">
1743 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1744 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1745 new file mode &lt;mode&gt;
1746 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1747 </div></div>
1748 <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
1749 the &lt;mode&gt; is different from the rest. Extended headers with
1750 information about detected contents movement (renames and
1751 copying detection) are designed to work with diff of two
1752 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1753 </li>
1754 <li>
1756 It is followed by two-line from-file/to-file header
1757 </p>
1758 <div class="literalblock">
1759 <div class="content">
1760 <pre><tt>--- a/file
1761 +++ b/file</tt></pre>
1762 </div></div>
1763 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1764 format, <tt>/dev/null</tt> is used to signal created or deleted
1765 files.</p></div>
1766 </li>
1767 <li>
1769 Chunk header format is modified to prevent people from
1770 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1771 was created for review of merge commit changes, and was not
1772 meant for apply. The change is similar to the change in the
1773 extended <em>index</em> header:
1774 </p>
1775 <div class="literalblock">
1776 <div class="content">
1777 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1778 </div></div>
1779 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1780 header for combined diff format.</p></div>
1781 </li>
1782 </ol></div>
1783 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1784 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
1785 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1786 compares two or more files file1, file2,&#8230; with one file X, and
1787 shows how X differs from each of fileN. One column for each of
1788 fileN is prepended to the output line to note how X&#8217;s line is
1789 different from it.</p></div>
1790 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1791 fileN but it does not appear in the result. A <tt>+</tt> character
1792 in the column N means that the line appears in the result,
1793 and fileN does not have that line (in other words, the line was
1794 added, from the point of view of that parent).</p></div>
1795 <div class="paragraph"><p>In the above example output, the function signature was changed
1796 from both files (hence two <tt>-</tt> removals from both file1 and
1797 file2, plus <tt>++</tt> to mean one line that was added does not appear
1798 in either file1 nor file2). Also eight other lines are the same
1799 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1800 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1801 merge commit with the merge result (i.e. file1..fileN are the
1802 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1803 two unresolved merge parents with the working tree file
1804 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1805 "their version").</p></div>
1806 </div>
1807 <h2 id="_other_diff_formats">other diff formats</h2>
1808 <div class="sectionbody">
1809 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1810 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1811 output. These options can be combined with other options, such as
1812 <tt>-p</tt>, and are meant for human consumption.</p></div>
1813 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1814 formats the pathnames compactly by combining common prefix and suffix of
1815 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1816 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1817 <div class="listingblock">
1818 <div class="content">
1819 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1820 </div></div>
1821 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1822 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1823 like this:</p></div>
1824 <div class="listingblock">
1825 <div class="content">
1826 <pre><tt>1 2 README
1827 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1828 </div></div>
1829 <div class="paragraph"><p>That is, from left to right:</p></div>
1830 <div class="olist arabic"><ol class="arabic">
1831 <li>
1833 the number of added lines;
1834 </p>
1835 </li>
1836 <li>
1838 a tab;
1839 </p>
1840 </li>
1841 <li>
1843 the number of deleted lines;
1844 </p>
1845 </li>
1846 <li>
1848 a tab;
1849 </p>
1850 </li>
1851 <li>
1853 pathname (possibly with rename/copy information);
1854 </p>
1855 </li>
1856 <li>
1858 a newline.
1859 </p>
1860 </li>
1861 </ol></div>
1862 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1863 <div class="listingblock">
1864 <div class="content">
1865 <pre><tt>1 2 README NUL
1866 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1867 </div></div>
1868 <div class="paragraph"><p>That is:</p></div>
1869 <div class="olist arabic"><ol class="arabic">
1870 <li>
1872 the number of added lines;
1873 </p>
1874 </li>
1875 <li>
1877 a tab;
1878 </p>
1879 </li>
1880 <li>
1882 the number of deleted lines;
1883 </p>
1884 </li>
1885 <li>
1887 a tab;
1888 </p>
1889 </li>
1890 <li>
1892 a NUL (only exists if renamed/copied);
1893 </p>
1894 </li>
1895 <li>
1897 pathname in preimage;
1898 </p>
1899 </li>
1900 <li>
1902 a NUL (only exists if renamed/copied);
1903 </p>
1904 </li>
1905 <li>
1907 pathname in postimage (only exists if renamed/copied);
1908 </p>
1909 </li>
1910 <li>
1912 a NUL.
1913 </p>
1914 </li>
1915 </ol></div>
1916 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1917 scripts that read the output to tell if the current record being read is
1918 a single-path record or a rename/copy record without reading ahead.
1919 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1920 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1921 </div>
1922 <h2 id="_operating_modes">Operating Modes</h2>
1923 <div class="sectionbody">
1924 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
1925 (using the <em>--cached</em> flag) or ask the diff logic to show any files
1926 that don&#8217;t match the stat state as being "tentatively changed". Both
1927 of these operations are very useful indeed.</p></div>
1928 </div>
1929 <h2 id="_cached_mode">Cached Mode</h2>
1930 <div class="sectionbody">
1931 <div class="paragraph"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div>
1932 <div class="literalblock">
1933 <div class="content">
1934 <pre><tt>show me the differences between HEAD and the current index
1935 contents (the ones I'd write using 'git write-tree')</tt></pre>
1936 </div></div>
1937 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
1938 some files in the index and are ready to commit. You want to see exactly
1939 <strong>what</strong> you are going to commit, without having to write a new tree
1940 object and compare it that way, and to do that, you just do</p></div>
1941 <div class="literalblock">
1942 <div class="content">
1943 <pre><tt>git diff-index --cached HEAD</tt></pre>
1944 </div></div>
1945 <div class="paragraph"><p>Example: let&#8217;s say I had renamed <tt>commit.c</tt> to <tt>git-commit.c</tt>, and I had
1946 done an <tt>update-index</tt> to make that effective in the index file.
1947 <tt>git diff-files</tt> wouldn&#8217;t show anything at all, since the index file
1948 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
1949 <div class="literalblock">
1950 <div class="content">
1951 <pre><tt>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
1952 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1953 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre>
1954 </div></div>
1955 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
1956 <div class="paragraph"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to
1957 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
1958 nicer for the case where you just want to check where you are.</p></div>
1959 <div class="paragraph"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are
1960 asking yourself "what have I already marked for being committed, and
1961 what&#8217;s the difference to a previous tree".</p></div>
1962 </div>
1963 <h2 id="_non_cached_mode">Non-cached Mode</h2>
1964 <div class="sectionbody">
1965 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
1966 the more useful of the two in that what it does can&#8217;t be emulated with
1967 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
1968 The non-cached version asks the question:</p></div>
1969 <div class="literalblock">
1970 <div class="content">
1971 <pre><tt>show me the differences between HEAD and the currently checked out
1972 tree - index contents _and_ files that aren't up-to-date</tt></pre>
1973 </div></div>
1974 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
1975 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
1976 output to a tee, but with a twist.</p></div>
1977 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
1978 a backing store thing for it, and we use the magic "all-zero" sha1 to
1979 show that. So let&#8217;s say that you have edited <tt>kernel/sched.c</tt>, but
1980 have not actually done a <em>git update-index</em> on it yet - there is no
1981 "object" associated with the new state, and you get:</p></div>
1982 <div class="literalblock">
1983 <div class="content">
1984 <pre><tt>torvalds@ppc970:~/v2.6/linux&gt; git diff-index --abbrev HEAD
1985 :100644 100664 7476bb... 000000... kernel/sched.c</tt></pre>
1986 </div></div>
1987 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is
1988 not up-to-date and may contain new stuff. The all-zero sha1 means that to
1989 get the real diff, you need to look at the object in the working directory
1990 directly rather than do an object-to-object diff.</p></div>
1991 <div class="admonitionblock">
1992 <table><tr>
1993 <td class="icon">
1994 <div class="title">Note</div>
1995 </td>
1996 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
1997 actually look at the contents of the file at all. So maybe
1998 <tt>kernel/sched.c</tt> hasn&#8217;t actually changed, and it&#8217;s just that you
1999 touched it. In either case, it&#8217;s a note that you need to
2000 <em>git update-index</em> it to make the index be in sync.</td>
2001 </tr></table>
2002 </div>
2003 <div class="admonitionblock">
2004 <table><tr>
2005 <td class="icon">
2006 <div class="title">Note</div>
2007 </td>
2008 <td class="content">You can have a mixture of files show up as "has been updated"
2009 and "is still dirty in the working directory" together. You can always
2010 tell which file is in which state, since the "has been updated" ones
2011 show a valid sha1, and the "not in sync with the index" ones will
2012 always have the special all-zero sha1.</td>
2013 </tr></table>
2014 </div>
2015 </div>
2016 <h2 id="_git">GIT</h2>
2017 <div class="sectionbody">
2018 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2019 </div>
2020 </div>
2021 <div id="footnotes"><hr /></div>
2022 <div id="footer">
2023 <div id="footer-text">
2024 Last updated 2011-09-21 23:01:14 PDT
2025 </div>
2026 </div>
2027 </body>
2028 </html>