Autogenerated HTML docs for v1.7.5-134-g1c08
[git/jnareb-git.git] / git-diff-index.html
blob0dd554cb5261ed410500e6dc609464f5b21a312a
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.4.5" />
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.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-diff-index(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-diff-index -
411 Compares content and mode of blobs between the index and repository
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="paragraph"><p><em>git diff-index</em> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</p></div>
418 </div>
419 <h2 id="_description">DESCRIPTION</h2>
420 <div class="sectionbody">
421 <div class="paragraph"><p>Compares the content and mode of the blobs found via a tree
422 object with the content of the current index and, optionally
423 ignoring the stat state of the file on disk. When paths are
424 specified, compares only those named paths. Otherwise all
425 entries in the index are compared.</p></div>
426 </div>
427 <h2 id="_options">OPTIONS</h2>
428 <div class="sectionbody">
429 <div class="dlist"><dl>
430 <dt class="hdlist1">
432 </dt>
433 <dt class="hdlist1">
435 </dt>
436 <dt class="hdlist1">
437 --patch
438 </dt>
439 <dd>
441 Generate patch (see section on generating patches).
443 </p>
444 </dd>
445 <dt class="hdlist1">
446 -U&lt;n&gt;
447 </dt>
448 <dt class="hdlist1">
449 --unified=&lt;n&gt;
450 </dt>
451 <dd>
453 Generate diffs with &lt;n&gt; lines of context instead of
454 the usual three.
455 Implies <tt>-p</tt>.
456 </p>
457 </dd>
458 <dt class="hdlist1">
459 --raw
460 </dt>
461 <dd>
463 Generate the raw format.
464 This is the default.
465 </p>
466 </dd>
467 <dt class="hdlist1">
468 --patch-with-raw
469 </dt>
470 <dd>
472 Synonym for <tt>-p --raw</tt>.
473 </p>
474 </dd>
475 <dt class="hdlist1">
476 --patience
477 </dt>
478 <dd>
480 Generate a diff using the "patience diff" algorithm.
481 </p>
482 </dd>
483 <dt class="hdlist1">
484 --stat[=&lt;width&gt;[,&lt;name-width&gt;]]
485 </dt>
486 <dd>
488 Generate a diffstat. You can override the default
489 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
490 The width of the filename part can be controlled by
491 giving another width to it separated by a comma.
492 </p>
493 </dd>
494 <dt class="hdlist1">
495 --numstat
496 </dt>
497 <dd>
499 Similar to <tt>--stat</tt>, but shows number of added and
500 deleted lines in decimal notation and pathname without
501 abbreviation, to make it more machine friendly. For
502 binary files, outputs two <tt>-</tt> instead of saying
503 <tt>0 0</tt>.
504 </p>
505 </dd>
506 <dt class="hdlist1">
507 --shortstat
508 </dt>
509 <dd>
511 Output only the last line of the <tt>--stat</tt> format containing total
512 number of modified files, as well as number of added and deleted
513 lines.
514 </p>
515 </dd>
516 <dt class="hdlist1">
517 --dirstat[=&lt;limit&gt;]
518 </dt>
519 <dd>
521 Output the distribution of relative amount of changes (number of lines added or
522 removed) for each sub-directory. Directories with changes below
523 a cut-off percent (3% by default) are not shown. The cut-off percent
524 can be set with <tt>--dirstat=&lt;limit&gt;</tt>. Changes in a child directory are not
525 counted for the parent directory, unless <tt>--cumulative</tt> is used.
526 </p>
527 <div class="paragraph"><p>Note that the <tt>--dirstat</tt> option computes the changes while ignoring
528 the amount of pure code movements within a file. In other words,
529 rearranging lines in a file is not counted as much as other changes.</p></div>
530 </dd>
531 <dt class="hdlist1">
532 --dirstat-by-file[=&lt;limit&gt;]
533 </dt>
534 <dd>
536 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
537 </p>
538 </dd>
539 <dt class="hdlist1">
540 --summary
541 </dt>
542 <dd>
544 Output a condensed summary of extended header information
545 such as creations, renames and mode changes.
546 </p>
547 </dd>
548 <dt class="hdlist1">
549 --patch-with-stat
550 </dt>
551 <dd>
553 Synonym for <tt>-p --stat</tt>.
554 </p>
555 </dd>
556 <dt class="hdlist1">
558 </dt>
559 <dd>
561 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
562 given, do not munge pathnames and use NULs as output field terminators.
563 </p>
564 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
565 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
566 respectively, and the pathname will be enclosed in double quotes if
567 any of those replacements occurred.</p></div>
568 </dd>
569 <dt class="hdlist1">
570 --name-only
571 </dt>
572 <dd>
574 Show only names of changed files.
575 </p>
576 </dd>
577 <dt class="hdlist1">
578 --name-status
579 </dt>
580 <dd>
582 Show only names and status of changed files. See the description
583 of the <tt>--diff-filter</tt> option on what the status letters mean.
584 </p>
585 </dd>
586 <dt class="hdlist1">
587 --submodule[=&lt;format&gt;]
588 </dt>
589 <dd>
591 Chose the output format for submodule differences. &lt;format&gt; can be one of
592 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
593 is used when this option is not given. <em>log</em> is the default value for this
594 option and lists the commits in that commit range like the <em>summary</em>
595 option of <a href="git-submodule.html">git-submodule(1)</a> does.
596 </p>
597 </dd>
598 <dt class="hdlist1">
599 --color[=&lt;when&gt;]
600 </dt>
601 <dd>
603 Show colored diff.
604 The value must be always (the default), never, or auto.
605 </p>
606 </dd>
607 <dt class="hdlist1">
608 --no-color
609 </dt>
610 <dd>
612 Turn off colored diff, even when the configuration file
613 gives the default to color output.
614 Same as <tt>--color=never</tt>.
615 </p>
616 </dd>
617 <dt class="hdlist1">
618 --word-diff[=&lt;mode&gt;]
619 </dt>
620 <dd>
622 Show a word diff, using the &lt;mode&gt; to delimit changed words.
623 By default, words are delimited by whitespace; see
624 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
625 must be one of:
626 </p>
627 <div class="dlist"><dl>
628 <dt class="hdlist1">
629 color
630 </dt>
631 <dd>
633 Highlight changed words using only colors. Implies <tt>--color</tt>.
634 </p>
635 </dd>
636 <dt class="hdlist1">
637 plain
638 </dt>
639 <dd>
641 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
642 attempts to escape the delimiters if they appear in the input,
643 so the output may be ambiguous.
644 </p>
645 </dd>
646 <dt class="hdlist1">
647 porcelain
648 </dt>
649 <dd>
651 Use a special line-based format intended for script
652 consumption. Added/removed/unchanged runs are printed in the
653 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
654 character at the beginning of the line and extending to the
655 end of the line. Newlines in the input are represented by a
656 tilde <tt>~</tt> on a line of its own.
657 </p>
658 </dd>
659 <dt class="hdlist1">
660 none
661 </dt>
662 <dd>
664 Disable word diff again.
665 </p>
666 </dd>
667 </dl></div>
668 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
669 highlight the changed parts in all modes if enabled.</p></div>
670 </dd>
671 <dt class="hdlist1">
672 --word-diff-regex=&lt;regex&gt;
673 </dt>
674 <dd>
676 Use &lt;regex&gt; to decide what a word is, instead of considering
677 runs of non-whitespace to be a word. Also implies
678 <tt>--word-diff</tt> unless it was already enabled.
679 </p>
680 <div class="paragraph"><p>Every non-overlapping match of the
681 &lt;regex&gt; is considered a word. Anything between these matches is
682 considered whitespace and ignored(!) for the purposes of finding
683 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
684 expression to make sure that it matches all non-whitespace characters.
685 A match that contains a newline is silently truncated(!) at the
686 newline.</p></div>
687 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
688 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
689 overrides any diff driver or configuration setting. Diff drivers
690 override configuration settings.</p></div>
691 </dd>
692 <dt class="hdlist1">
693 --color-words[=&lt;regex&gt;]
694 </dt>
695 <dd>
697 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
698 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
699 </p>
700 </dd>
701 <dt class="hdlist1">
702 --no-renames
703 </dt>
704 <dd>
706 Turn off rename detection, even when the configuration
707 file gives the default to do so.
708 </p>
709 </dd>
710 <dt class="hdlist1">
711 --check
712 </dt>
713 <dd>
715 Warn if changes introduce trailing whitespace
716 or an indent that uses a space before a tab. Exits with
717 non-zero status if problems are found. Not compatible with
718 --exit-code.
719 </p>
720 </dd>
721 <dt class="hdlist1">
722 --full-index
723 </dt>
724 <dd>
726 Instead of the first handful of characters, show the full
727 pre- and post-image blob object names on the "index"
728 line when generating patch format output.
729 </p>
730 </dd>
731 <dt class="hdlist1">
732 --binary
733 </dt>
734 <dd>
736 In addition to <tt>--full-index</tt>, output a binary diff that
737 can be applied with <tt>git-apply</tt>.
738 </p>
739 </dd>
740 <dt class="hdlist1">
741 --abbrev[=&lt;n&gt;]
742 </dt>
743 <dd>
745 Instead of showing the full 40-byte hexadecimal object
746 name in diff-raw format output and diff-tree header
747 lines, show only a partial prefix. This is
748 independent of the <tt>--full-index</tt> option above, which controls
749 the diff-patch output format. Non default number of
750 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
751 </p>
752 </dd>
753 <dt class="hdlist1">
754 -B[&lt;n&gt;][/&lt;m&gt;]
755 </dt>
756 <dt class="hdlist1">
757 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
758 </dt>
759 <dd>
761 Break complete rewrite changes into pairs of delete and
762 create. This serves two purposes:
763 </p>
764 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
765 not as a series of deletion and insertion mixed together with a very
766 few lines that happen to match textually as the context, but as a
767 single deletion of everything old followed by a single insertion of
768 everything new, and the number <tt>m</tt> controls this aspect of the -B
769 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
770 original should remain in the result for git to consider it a total
771 rewrite (i.e. otherwise the resulting patch will be a series of
772 deletion and insertion mixed together with context lines).</p></div>
773 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
774 source of a rename (usually -M only considers a file that disappeared
775 as the source of a rename), and the number <tt>n</tt> controls this aspect of
776 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
777 addition and deletion compared to 20% or more of the file&#8217;s size are
778 eligible for being picked up as a possible source of a rename to
779 another file.</p></div>
780 </dd>
781 <dt class="hdlist1">
782 -M[&lt;n&gt;]
783 </dt>
784 <dt class="hdlist1">
785 --find-renames[=&lt;n&gt;]
786 </dt>
787 <dd>
789 Detect renames.
790 If <tt>n</tt> is specified, it is a is a threshold on the similarity
791 index (i.e. amount of addition/deletions compared to the
792 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
793 delete/add pair to be a rename if more than 90% of the file
794 hasn&#8217;t changed.
795 </p>
796 </dd>
797 <dt class="hdlist1">
798 -C[&lt;n&gt;]
799 </dt>
800 <dt class="hdlist1">
801 --find-copies[=&lt;n&gt;]
802 </dt>
803 <dd>
805 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
806 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
807 </p>
808 </dd>
809 <dt class="hdlist1">
810 --find-copies-harder
811 </dt>
812 <dd>
814 For performance reasons, by default, <tt>-C</tt> option finds copies only
815 if the original file of the copy was modified in the same
816 changeset. This flag makes the command
817 inspect unmodified files as candidates for the source of
818 copy. This is a very expensive operation for large
819 projects, so use it with caution. Giving more than one
820 <tt>-C</tt> option has the same effect.
821 </p>
822 </dd>
823 <dt class="hdlist1">
825 </dt>
826 <dt class="hdlist1">
827 --irreversible-delete
828 </dt>
829 <dd>
831 Omit the preimage for deletes, i.e. print only the header but not
832 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
833 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
834 solely for people who want to just concentrate on reviewing the
835 text after the change. In addition, the output obviously lack
836 enough information to apply such a patch in reverse, even manually,
837 hence the name of the option.
838 </p>
839 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
840 of a delete/create pair.</p></div>
841 </dd>
842 <dt class="hdlist1">
843 -l&lt;num&gt;
844 </dt>
845 <dd>
847 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
848 is the number of potential rename/copy targets. This
849 option prevents rename/copy detection from running if
850 the number of rename/copy targets exceeds the specified
851 number.
852 </p>
853 </dd>
854 <dt class="hdlist1">
855 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
856 </dt>
857 <dd>
859 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
860 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
861 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
862 are Unmerged (<tt>U</tt>), are
863 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
864 Any combination of the filter characters (including none) can be used.
865 When <tt>*</tt> (All-or-none) is added to the combination, all
866 paths are selected if there is any file that matches
867 other criteria in the comparison; if there is no file
868 that matches other criteria, nothing is selected.
869 </p>
870 </dd>
871 <dt class="hdlist1">
872 -S&lt;string&gt;
873 </dt>
874 <dd>
876 Look for differences that introduce or remove an instance of
877 &lt;string&gt;. Note that this is different than the string simply
878 appearing in diff output; see the <em>pickaxe</em> entry in
879 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
880 </p>
881 </dd>
882 <dt class="hdlist1">
883 -G&lt;regex&gt;
884 </dt>
885 <dd>
887 Look for differences whose added or removed line matches
888 the given &lt;regex&gt;.
889 </p>
890 </dd>
891 <dt class="hdlist1">
892 --pickaxe-all
893 </dt>
894 <dd>
896 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
897 changeset, not just the files that contain the change
898 in &lt;string&gt;.
899 </p>
900 </dd>
901 <dt class="hdlist1">
902 --pickaxe-regex
903 </dt>
904 <dd>
906 Make the &lt;string&gt; not a plain string but an extended POSIX
907 regex to match.
908 </p>
909 </dd>
910 <dt class="hdlist1">
911 -O&lt;orderfile&gt;
912 </dt>
913 <dd>
915 Output the patch in the order specified in the
916 &lt;orderfile&gt;, which has one shell glob pattern per line.
917 </p>
918 </dd>
919 <dt class="hdlist1">
921 </dt>
922 <dd>
924 Swap two inputs; that is, show differences from index or
925 on-disk file to tree contents.
926 </p>
927 </dd>
928 <dt class="hdlist1">
929 --relative[=&lt;path&gt;]
930 </dt>
931 <dd>
933 When run from a subdirectory of the project, it can be
934 told to exclude changes outside the directory and show
935 pathnames relative to it with this option. When you are
936 not in a subdirectory (e.g. in a bare repository), you
937 can name which subdirectory to make the output relative
938 to by giving a &lt;path&gt; as an argument.
939 </p>
940 </dd>
941 <dt class="hdlist1">
943 </dt>
944 <dt class="hdlist1">
945 --text
946 </dt>
947 <dd>
949 Treat all files as text.
950 </p>
951 </dd>
952 <dt class="hdlist1">
953 --ignore-space-at-eol
954 </dt>
955 <dd>
957 Ignore changes in whitespace at EOL.
958 </p>
959 </dd>
960 <dt class="hdlist1">
962 </dt>
963 <dt class="hdlist1">
964 --ignore-space-change
965 </dt>
966 <dd>
968 Ignore changes in amount of whitespace. This ignores whitespace
969 at line end, and considers all other sequences of one or
970 more whitespace characters to be equivalent.
971 </p>
972 </dd>
973 <dt class="hdlist1">
975 </dt>
976 <dt class="hdlist1">
977 --ignore-all-space
978 </dt>
979 <dd>
981 Ignore whitespace when comparing lines. This ignores
982 differences even if one line has whitespace where the other
983 line has none.
984 </p>
985 </dd>
986 <dt class="hdlist1">
987 --inter-hunk-context=&lt;lines&gt;
988 </dt>
989 <dd>
991 Show the context between diff hunks, up to the specified number
992 of lines, thereby fusing hunks that are close to each other.
993 </p>
994 </dd>
995 <dt class="hdlist1">
996 --exit-code
997 </dt>
998 <dd>
1000 Make the program exit with codes similar to diff(1).
1001 That is, it exits with 1 if there were differences and
1002 0 means no differences.
1003 </p>
1004 </dd>
1005 <dt class="hdlist1">
1006 --quiet
1007 </dt>
1008 <dd>
1010 Disable all output of the program. Implies <tt>--exit-code</tt>.
1011 </p>
1012 </dd>
1013 <dt class="hdlist1">
1014 --ext-diff
1015 </dt>
1016 <dd>
1018 Allow an external diff helper to be executed. If you set an
1019 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1020 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1021 </p>
1022 </dd>
1023 <dt class="hdlist1">
1024 --no-ext-diff
1025 </dt>
1026 <dd>
1028 Disallow external diff drivers.
1029 </p>
1030 </dd>
1031 <dt class="hdlist1">
1032 --ignore-submodules[=&lt;when&gt;]
1033 </dt>
1034 <dd>
1036 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1037 either "none", "untracked", "dirty" or "all", which is the default
1038 Using "none" will consider the submodule modified when it either contains
1039 untracked or modified files or its HEAD differs from the commit recorded
1040 in the superproject and can be used to override any settings of the
1041 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1042 "untracked" is used submodules are not considered dirty when they only
1043 contain untracked content (but they are still scanned for modified
1044 content). Using "dirty" ignores all changes to the work tree of submodules,
1045 only changes to the commits stored in the superproject are shown (this was
1046 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1047 </p>
1048 </dd>
1049 <dt class="hdlist1">
1050 --src-prefix=&lt;prefix&gt;
1051 </dt>
1052 <dd>
1054 Show the given source prefix instead of "a/".
1055 </p>
1056 </dd>
1057 <dt class="hdlist1">
1058 --dst-prefix=&lt;prefix&gt;
1059 </dt>
1060 <dd>
1062 Show the given destination prefix instead of "b/".
1063 </p>
1064 </dd>
1065 <dt class="hdlist1">
1066 --no-prefix
1067 </dt>
1068 <dd>
1070 Do not show any source or destination prefix.
1071 </p>
1072 </dd>
1073 </dl></div>
1074 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1075 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1076 <div class="dlist"><dl>
1077 <dt class="hdlist1">
1078 &lt;tree-ish&gt;
1079 </dt>
1080 <dd>
1082 The id of a tree object to diff against.
1083 </p>
1084 </dd>
1085 <dt class="hdlist1">
1086 --cached
1087 </dt>
1088 <dd>
1090 do not consider the on-disk file at all
1091 </p>
1092 </dd>
1093 <dt class="hdlist1">
1095 </dt>
1096 <dd>
1098 By default, files recorded in the index but not checked
1099 out are reported as deleted. This flag makes
1100 <em>git diff-index</em> say that all non-checked-out files are up
1101 to date.
1102 </p>
1103 </dd>
1104 </dl></div>
1105 </div>
1106 <h2 id="_raw_output_format">Raw output format</h2>
1107 <div class="sectionbody">
1108 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1109 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1110 <div class="paragraph"><p>These commands all compare two sets of things; what is
1111 compared differs:</p></div>
1112 <div class="dlist"><dl>
1113 <dt class="hdlist1">
1114 git-diff-index &lt;tree-ish&gt;
1115 </dt>
1116 <dd>
1118 compares the &lt;tree-ish&gt; and the files on the filesystem.
1119 </p>
1120 </dd>
1121 <dt class="hdlist1">
1122 git-diff-index --cached &lt;tree-ish&gt;
1123 </dt>
1124 <dd>
1126 compares the &lt;tree-ish&gt; and the index.
1127 </p>
1128 </dd>
1129 <dt class="hdlist1">
1130 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1131 </dt>
1132 <dd>
1134 compares the trees named by the two arguments.
1135 </p>
1136 </dd>
1137 <dt class="hdlist1">
1138 git-diff-files [&lt;pattern&gt;&#8230;]
1139 </dt>
1140 <dd>
1142 compares the index and the files on the filesystem.
1143 </p>
1144 </dd>
1145 </dl></div>
1146 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1147 what is being compared. After that, all the commands print one output
1148 line per changed file.</p></div>
1149 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1150 <div class="listingblock">
1151 <div class="content">
1152 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1153 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1154 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1155 create :000000 100644 0000000... 1234567... A file4
1156 delete :100644 000000 1234567... 0000000... D file5
1157 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1158 </div></div>
1159 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1160 <div class="olist arabic"><ol class="arabic">
1161 <li>
1163 a colon.
1164 </p>
1165 </li>
1166 <li>
1168 mode for "src"; 000000 if creation or unmerged.
1169 </p>
1170 </li>
1171 <li>
1173 a space.
1174 </p>
1175 </li>
1176 <li>
1178 mode for "dst"; 000000 if deletion or unmerged.
1179 </p>
1180 </li>
1181 <li>
1183 a space.
1184 </p>
1185 </li>
1186 <li>
1188 sha1 for "src"; 0{40} if creation or unmerged.
1189 </p>
1190 </li>
1191 <li>
1193 a space.
1194 </p>
1195 </li>
1196 <li>
1198 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1199 </p>
1200 </li>
1201 <li>
1203 a space.
1204 </p>
1205 </li>
1206 <li>
1208 status, followed by optional "score" number.
1209 </p>
1210 </li>
1211 <li>
1213 a tab or a NUL when <em>-z</em> option is used.
1214 </p>
1215 </li>
1216 <li>
1218 path for "src"
1219 </p>
1220 </li>
1221 <li>
1223 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1224 </p>
1225 </li>
1226 <li>
1228 path for "dst"; only exists for C or R.
1229 </p>
1230 </li>
1231 <li>
1233 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1234 </p>
1235 </li>
1236 </ol></div>
1237 <div class="paragraph"><p>Possible status letters are:</p></div>
1238 <div class="ulist"><ul>
1239 <li>
1241 A: addition of a file
1242 </p>
1243 </li>
1244 <li>
1246 C: copy of a file into a new one
1247 </p>
1248 </li>
1249 <li>
1251 D: deletion of a file
1252 </p>
1253 </li>
1254 <li>
1256 M: modification of the contents or mode of a file
1257 </p>
1258 </li>
1259 <li>
1261 R: renaming of a file
1262 </p>
1263 </li>
1264 <li>
1266 T: change in the type of the file
1267 </p>
1268 </li>
1269 <li>
1271 U: file is unmerged (you must complete the merge before it can
1272 be committed)
1273 </p>
1274 </li>
1275 <li>
1277 X: "unknown" change type (most probably a bug, please report it)
1278 </p>
1279 </li>
1280 </ul></div>
1281 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1282 percentage of similarity between the source and target of the move or
1283 copy), and are the only ones to be so.</p></div>
1284 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1285 and it is out of sync with the index.</p></div>
1286 <div class="paragraph"><p>Example:</p></div>
1287 <div class="listingblock">
1288 <div class="content">
1289 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1290 </div></div>
1291 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1292 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1293 respectively.</p></div>
1294 </div>
1295 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1296 <div class="sectionbody">
1297 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1298 can take <em>-c</em> or <em>--cc</em> option
1299 to generate diff output also for merge commits. The output differs
1300 from the format described above in the following way:</p></div>
1301 <div class="olist arabic"><ol class="arabic">
1302 <li>
1304 there is a colon for each parent
1305 </p>
1306 </li>
1307 <li>
1309 there are more "src" modes and "src" sha1
1310 </p>
1311 </li>
1312 <li>
1314 status is concatenated status characters for each parent
1315 </p>
1316 </li>
1317 <li>
1319 no optional "score" number
1320 </p>
1321 </li>
1322 <li>
1324 single path, only for "dst"
1325 </p>
1326 </li>
1327 </ol></div>
1328 <div class="paragraph"><p>Example:</p></div>
1329 <div class="listingblock">
1330 <div class="content">
1331 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1332 </div></div>
1333 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1334 all parents.</p></div>
1335 </div>
1336 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1337 <div class="sectionbody">
1338 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1339 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1340 "git log" with the "-p" option, they
1341 do not produce the output described above; instead they produce a
1342 patch file. You can customize the creation of such patches via the
1343 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1344 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1345 diff format:</p></div>
1346 <div class="olist arabic"><ol class="arabic">
1347 <li>
1349 It is preceded with a "git diff" header that looks like this:
1350 </p>
1351 <div class="literalblock">
1352 <div class="content">
1353 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1354 </div></div>
1355 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1356 involved. Especially, even for a creation or a deletion,
1357 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1358 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1359 name of the source file of the rename/copy and the name of
1360 the file that rename/copy produces, respectively.</p></div>
1361 </li>
1362 <li>
1364 It is followed by one or more extended header lines:
1365 </p>
1366 <div class="literalblock">
1367 <div class="content">
1368 <pre><tt>old mode &lt;mode&gt;
1369 new mode &lt;mode&gt;
1370 deleted file mode &lt;mode&gt;
1371 new file mode &lt;mode&gt;
1372 copy from &lt;path&gt;
1373 copy to &lt;path&gt;
1374 rename from &lt;path&gt;
1375 rename to &lt;path&gt;
1376 similarity index &lt;number&gt;
1377 dissimilarity index &lt;number&gt;
1378 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1379 </div></div>
1380 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1381 and file permission bits.</p></div>
1382 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1383 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1384 the dissimilarity index is the percentage of changed lines. It
1385 is a rounded down integer, followed by a percent sign. The
1386 similarity index value of 100% is thus reserved for two equal
1387 files, while 100% dissimilarity means that no line from the old
1388 file made it into the new one.</p></div>
1389 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1390 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1391 separate lines indicate the old and the new mode.</p></div>
1392 </li>
1393 <li>
1395 TAB, LF, double quote and backslash characters in pathnames
1396 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1397 If there is need for such substitution then the whole
1398 pathname is put in double quotes.
1399 </p>
1400 </li>
1401 <li>
1403 All the <tt>file1</tt> files in the output refer to files before the
1404 commit, and all the <tt>file2</tt> files refer to files after the commit.
1405 It is incorrect to apply each change to each file sequentially. For
1406 example, this patch will swap a and b:
1407 </p>
1408 <div class="literalblock">
1409 <div class="content">
1410 <pre><tt>diff --git a/a b/b
1411 rename from a
1412 rename to b
1413 diff --git a/b b/a
1414 rename from b
1415 rename to a</tt></pre>
1416 </div></div>
1417 </li>
1418 </ol></div>
1419 </div>
1420 <h2 id="_combined_diff_format">combined diff format</h2>
1421 <div class="sectionbody">
1422 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1423 produce a <em>combined diff</em> when showing a merge. This is the default
1424 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1425 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1426 of these commands to force generation of diffs with individual parents
1427 of a merge.</p></div>
1428 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1429 <div class="listingblock">
1430 <div class="content">
1431 <pre><tt>diff --combined describe.c
1432 index fabadb8,cc95eb0..4866510
1433 --- a/describe.c
1434 +++ b/describe.c
1435 @@@ -98,20 -98,12 +98,20 @@@
1436 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1439 - static void describe(char *arg)
1440 -static void describe(struct commit *cmit, int last_one)
1441 ++static void describe(char *arg, int last_one)
1443 + unsigned char sha1[20];
1444 + struct commit *cmit;
1445 struct commit_list *list;
1446 static int initialized = 0;
1447 struct commit_name *n;
1449 + if (get_sha1(arg, sha1) &lt; 0)
1450 + usage(describe_usage);
1451 + cmit = lookup_commit_reference(sha1);
1452 + if (!cmit)
1453 + usage(describe_usage);
1455 if (!initialized) {
1456 initialized = 1;
1457 for_each_ref(get_name);</tt></pre>
1458 </div></div>
1459 <div class="olist arabic"><ol class="arabic">
1460 <li>
1462 It is preceded with a "git diff" header, that looks like
1463 this (when <em>-c</em> option is used):
1464 </p>
1465 <div class="literalblock">
1466 <div class="content">
1467 <pre><tt>diff --combined file</tt></pre>
1468 </div></div>
1469 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1470 <div class="literalblock">
1471 <div class="content">
1472 <pre><tt>diff --cc file</tt></pre>
1473 </div></div>
1474 </li>
1475 <li>
1477 It is followed by one or more extended header lines
1478 (this example shows a merge with two parents):
1479 </p>
1480 <div class="literalblock">
1481 <div class="content">
1482 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1483 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1484 new file mode &lt;mode&gt;
1485 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1486 </div></div>
1487 <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
1488 the &lt;mode&gt; is different from the rest. Extended headers with
1489 information about detected contents movement (renames and
1490 copying detection) are designed to work with diff of two
1491 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1492 </li>
1493 <li>
1495 It is followed by two-line from-file/to-file header
1496 </p>
1497 <div class="literalblock">
1498 <div class="content">
1499 <pre><tt>--- a/file
1500 +++ b/file</tt></pre>
1501 </div></div>
1502 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1503 format, <tt>/dev/null</tt> is used to signal created or deleted
1504 files.</p></div>
1505 </li>
1506 <li>
1508 Chunk header format is modified to prevent people from
1509 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1510 was created for review of merge commit changes, and was not
1511 meant for apply. The change is similar to the change in the
1512 extended <em>index</em> header:
1513 </p>
1514 <div class="literalblock">
1515 <div class="content">
1516 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1517 </div></div>
1518 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1519 header for combined diff format.</p></div>
1520 </li>
1521 </ol></div>
1522 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1523 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
1524 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1525 compares two or more files file1, file2,&#8230; with one file X, and
1526 shows how X differs from each of fileN. One column for each of
1527 fileN is prepended to the output line to note how X&#8217;s line is
1528 different from it.</p></div>
1529 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1530 fileN but it does not appear in the result. A <tt>+</tt> character
1531 in the column N means that the line appears in the result,
1532 and fileN does not have that line (in other words, the line was
1533 added, from the point of view of that parent).</p></div>
1534 <div class="paragraph"><p>In the above example output, the function signature was changed
1535 from both files (hence two <tt>-</tt> removals from both file1 and
1536 file2, plus <tt>++</tt> to mean one line that was added does not appear
1537 in either file1 nor file2). Also eight other lines are the same
1538 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1539 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1540 merge commit with the merge result (i.e. file1..fileN are the
1541 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1542 two unresolved merge parents with the working tree file
1543 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1544 "their version").</p></div>
1545 </div>
1546 <h2 id="_other_diff_formats">other diff formats</h2>
1547 <div class="sectionbody">
1548 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1549 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1550 output. These options can be combined with other options, such as
1551 <tt>-p</tt>, and are meant for human consumption.</p></div>
1552 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1553 formats the pathnames compactly by combining common prefix and suffix of
1554 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1555 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1556 <div class="listingblock">
1557 <div class="content">
1558 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1559 </div></div>
1560 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1561 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1562 like this:</p></div>
1563 <div class="listingblock">
1564 <div class="content">
1565 <pre><tt>1 2 README
1566 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1567 </div></div>
1568 <div class="paragraph"><p>That is, from left to right:</p></div>
1569 <div class="olist arabic"><ol class="arabic">
1570 <li>
1572 the number of added lines;
1573 </p>
1574 </li>
1575 <li>
1577 a tab;
1578 </p>
1579 </li>
1580 <li>
1582 the number of deleted lines;
1583 </p>
1584 </li>
1585 <li>
1587 a tab;
1588 </p>
1589 </li>
1590 <li>
1592 pathname (possibly with rename/copy information);
1593 </p>
1594 </li>
1595 <li>
1597 a newline.
1598 </p>
1599 </li>
1600 </ol></div>
1601 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1602 <div class="listingblock">
1603 <div class="content">
1604 <pre><tt>1 2 README NUL
1605 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1606 </div></div>
1607 <div class="paragraph"><p>That is:</p></div>
1608 <div class="olist arabic"><ol class="arabic">
1609 <li>
1611 the number of added lines;
1612 </p>
1613 </li>
1614 <li>
1616 a tab;
1617 </p>
1618 </li>
1619 <li>
1621 the number of deleted lines;
1622 </p>
1623 </li>
1624 <li>
1626 a tab;
1627 </p>
1628 </li>
1629 <li>
1631 a NUL (only exists if renamed/copied);
1632 </p>
1633 </li>
1634 <li>
1636 pathname in preimage;
1637 </p>
1638 </li>
1639 <li>
1641 a NUL (only exists if renamed/copied);
1642 </p>
1643 </li>
1644 <li>
1646 pathname in postimage (only exists if renamed/copied);
1647 </p>
1648 </li>
1649 <li>
1651 a NUL.
1652 </p>
1653 </li>
1654 </ol></div>
1655 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1656 scripts that read the output to tell if the current record being read is
1657 a single-path record or a rename/copy record without reading ahead.
1658 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1659 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1660 </div>
1661 <h2 id="_operating_modes">Operating Modes</h2>
1662 <div class="sectionbody">
1663 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
1664 (using the <em>--cached</em> flag) or ask the diff logic to show any files
1665 that don&#8217;t match the stat state as being "tentatively changed". Both
1666 of these operations are very useful indeed.</p></div>
1667 </div>
1668 <h2 id="_cached_mode">Cached Mode</h2>
1669 <div class="sectionbody">
1670 <div class="paragraph"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div>
1671 <div class="literalblock">
1672 <div class="content">
1673 <pre><tt>show me the differences between HEAD and the current index
1674 contents (the ones I'd write using 'git write-tree')</tt></pre>
1675 </div></div>
1676 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
1677 some files in the index and are ready to commit. You want to see exactly
1678 <strong>what</strong> you are going to commit, without having to write a new tree
1679 object and compare it that way, and to do that, you just do</p></div>
1680 <div class="literalblock">
1681 <div class="content">
1682 <pre><tt>git diff-index --cached HEAD</tt></pre>
1683 </div></div>
1684 <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
1685 done an <tt>update-index</tt> to make that effective in the index file.
1686 <tt>git diff-files</tt> wouldn&#8217;t show anything at all, since the index file
1687 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
1688 <div class="literalblock">
1689 <div class="content">
1690 <pre><tt>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
1691 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1692 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre>
1693 </div></div>
1694 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
1695 <div class="paragraph"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to
1696 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
1697 nicer for the case where you just want to check where you are.</p></div>
1698 <div class="paragraph"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are
1699 asking yourself "what have I already marked for being committed, and
1700 what&#8217;s the difference to a previous tree".</p></div>
1701 </div>
1702 <h2 id="_non_cached_mode">Non-cached Mode</h2>
1703 <div class="sectionbody">
1704 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
1705 the more useful of the two in that what it does can&#8217;t be emulated with
1706 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
1707 The non-cached version asks the question:</p></div>
1708 <div class="literalblock">
1709 <div class="content">
1710 <pre><tt>show me the differences between HEAD and the currently checked out
1711 tree - index contents _and_ files that aren't up-to-date</tt></pre>
1712 </div></div>
1713 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
1714 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
1715 output to a tee, but with a twist.</p></div>
1716 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
1717 a backing store thing for it, and we use the magic "all-zero" sha1 to
1718 show that. So let&#8217;s say that you have edited <tt>kernel/sched.c</tt>, but
1719 have not actually done a <em>git update-index</em> on it yet - there is no
1720 "object" associated with the new state, and you get:</p></div>
1721 <div class="literalblock">
1722 <div class="content">
1723 <pre><tt>torvalds@ppc970:~/v2.6/linux&gt; git diff-index HEAD
1724 *100644-&gt;100664 blob 7476bb......-&gt;000000...... kernel/sched.c</tt></pre>
1725 </div></div>
1726 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is
1727 not up-to-date and may contain new stuff. The all-zero sha1 means that to
1728 get the real diff, you need to look at the object in the working directory
1729 directly rather than do an object-to-object diff.</p></div>
1730 <div class="admonitionblock">
1731 <table><tr>
1732 <td class="icon">
1733 <div class="title">Note</div>
1734 </td>
1735 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
1736 actually look at the contents of the file at all. So maybe
1737 <tt>kernel/sched.c</tt> hasn&#8217;t actually changed, and it&#8217;s just that you
1738 touched it. In either case, it&#8217;s a note that you need to
1739 <em>git update-index</em> it to make the index be in sync.</td>
1740 </tr></table>
1741 </div>
1742 <div class="admonitionblock">
1743 <table><tr>
1744 <td class="icon">
1745 <div class="title">Note</div>
1746 </td>
1747 <td class="content">You can have a mixture of files show up as "has been updated"
1748 and "is still dirty in the working directory" together. You can always
1749 tell which file is in which state, since the "has been updated" ones
1750 show a valid sha1, and the "not in sync with the index" ones will
1751 always have the special all-zero sha1.</td>
1752 </tr></table>
1753 </div>
1754 </div>
1755 <h2 id="_git">GIT</h2>
1756 <div class="sectionbody">
1757 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1758 </div>
1759 <div id="footer">
1760 <div id="footer-text">
1761 Last updated 2011-03-15 23:30:13 UTC
1762 </div>
1763 </div>
1764 </body>
1765 </html>