Autogenerated HTML docs for v1.7.5.1-339-gb602ed
[git/jnareb-git.git] / git-diff.html
blobf33a7aaf9d721bfd8e4bbed5e476ff0075765013
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(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(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-diff -
411 Show changes between commits, commit and working tree, etc
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git diff</em> [options] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
419 <em>git diff</em> [options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
420 <em>git diff</em> [options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
421 <em>git diff</em> [options] [--no-index] [--] &lt;path&gt; &lt;path&gt;</div>
422 <div class="verseblock-attribution">
423 </div></div>
424 </div>
425 <h2 id="_description">DESCRIPTION</h2>
426 <div class="sectionbody">
427 <div class="paragraph"><p>Show changes between the working tree and the index or a tree, changes
428 between the index and a tree, changes between two trees, or changes
429 between two files on disk.</p></div>
430 <div class="dlist"><dl>
431 <dt class="hdlist1">
432 <em>git diff</em> [--options] [--] [&lt;path&gt;&#8230;]
433 </dt>
434 <dd>
436 This form is to view the changes you made relative to
437 the index (staging area for the next commit). In other
438 words, the differences are what you <em>could</em> tell git to
439 further add to the index but you still haven&#8217;t. You can
440 stage these changes by using <a href="git-add.html">git-add(1)</a>.
441 </p>
442 <div class="paragraph"><p>If exactly two paths are given and at least one points outside
443 the current repository, <em>git diff</em> will compare the two files /
444 directories. This behavior can be forced by --no-index.</p></div>
445 </dd>
446 <dt class="hdlist1">
447 <em>git diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
448 </dt>
449 <dd>
451 This form is to view the changes you staged for the next
452 commit relative to the named &lt;commit&gt;. Typically you
453 would want comparison with the latest commit, so if you
454 do not give &lt;commit&gt;, it defaults to HEAD.
455 If HEAD does not exist (e.g. unborned branches) and
456 &lt;commit&gt; is not given, it shows all staged changes.
457 --staged is a synonym of --cached.
458 </p>
459 </dd>
460 <dt class="hdlist1">
461 <em>git diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
462 </dt>
463 <dd>
465 This form is to view the changes you have in your
466 working tree relative to the named &lt;commit&gt;. You can
467 use HEAD to compare it with the latest commit, or a
468 branch name to compare with the tip of a different
469 branch.
470 </p>
471 </dd>
472 <dt class="hdlist1">
473 <em>git diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
474 </dt>
475 <dd>
477 This is to view the changes between two arbitrary
478 &lt;commit&gt;.
479 </p>
480 </dd>
481 <dt class="hdlist1">
482 <em>git diff</em> [--options] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
483 </dt>
484 <dd>
486 This is synonymous to the previous form. If &lt;commit&gt; on
487 one side is omitted, it will have the same effect as
488 using HEAD instead.
489 </p>
490 </dd>
491 <dt class="hdlist1">
492 <em>git diff</em> [--options] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
493 </dt>
494 <dd>
496 This form is to view the changes on the branch containing
497 and up to the second &lt;commit&gt;, starting at a common ancestor
498 of both &lt;commit&gt;. "git diff A...B" is equivalent to
499 "git diff $(git-merge-base A B) B". You can omit any one
500 of &lt;commit&gt;, which has the same effect as using HEAD instead.
501 </p>
502 </dd>
503 </dl></div>
504 <div class="paragraph"><p>Just in case if you are doing something exotic, it should be
505 noted that all of the &lt;commit&gt; in the above description, except
506 in the last two forms that use ".." notations, can be any
507 &lt;tree&gt;. The third form (<em>git diff &lt;commit&gt; &lt;commit&gt;</em>) can also
508 be used to compare two &lt;blob&gt; objects.</p></div>
509 <div class="paragraph"><p>For a more complete list of ways to spell &lt;commit&gt;, see
510 "SPECIFYING REVISIONS" section in <a href="gitrevisions.html">gitrevisions(7)</a>.
511 However, "diff" is about comparing two <em>endpoints</em>, not ranges,
512 and the range notations ("&lt;commit&gt;..&lt;commit&gt;" and
513 "&lt;commit&gt;...&lt;commit&gt;") do not mean a range as defined in the
514 "SPECIFYING RANGES" section in <a href="gitrevisions.html">gitrevisions(7)</a>.</p></div>
515 </div>
516 <h2 id="_options">OPTIONS</h2>
517 <div class="sectionbody">
518 <div class="dlist"><dl>
519 <dt class="hdlist1">
521 </dt>
522 <dt class="hdlist1">
524 </dt>
525 <dt class="hdlist1">
526 --patch
527 </dt>
528 <dd>
530 Generate patch (see section on generating patches).
531 This is the default.
532 </p>
533 </dd>
534 <dt class="hdlist1">
535 -U&lt;n&gt;
536 </dt>
537 <dt class="hdlist1">
538 --unified=&lt;n&gt;
539 </dt>
540 <dd>
542 Generate diffs with &lt;n&gt; lines of context instead of
543 the usual three.
544 Implies <tt>-p</tt>.
545 </p>
546 </dd>
547 <dt class="hdlist1">
548 --raw
549 </dt>
550 <dd>
552 Generate the raw format.
554 </p>
555 </dd>
556 <dt class="hdlist1">
557 --patch-with-raw
558 </dt>
559 <dd>
561 Synonym for <tt>-p --raw</tt>.
562 </p>
563 </dd>
564 <dt class="hdlist1">
565 --patience
566 </dt>
567 <dd>
569 Generate a diff using the "patience diff" algorithm.
570 </p>
571 </dd>
572 <dt class="hdlist1">
573 --stat[=&lt;width&gt;[,&lt;name-width&gt;]]
574 </dt>
575 <dd>
577 Generate a diffstat. You can override the default
578 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
579 The width of the filename part can be controlled by
580 giving another width to it separated by a comma.
581 </p>
582 </dd>
583 <dt class="hdlist1">
584 --numstat
585 </dt>
586 <dd>
588 Similar to <tt>--stat</tt>, but shows number of added and
589 deleted lines in decimal notation and pathname without
590 abbreviation, to make it more machine friendly. For
591 binary files, outputs two <tt>-</tt> instead of saying
592 <tt>0 0</tt>.
593 </p>
594 </dd>
595 <dt class="hdlist1">
596 --shortstat
597 </dt>
598 <dd>
600 Output only the last line of the <tt>--stat</tt> format containing total
601 number of modified files, as well as number of added and deleted
602 lines.
603 </p>
604 </dd>
605 <dt class="hdlist1">
606 --dirstat[=&lt;param1,param2,&#8230;&gt;]
607 </dt>
608 <dd>
610 Output the distribution of relative amount of changes for each
611 sub-directory. The behavior of <tt>--dirstat</tt> can be customized by
612 passing it a comma separated list of parameters.
613 The defaults are controlled by the <tt>diff.dirstat</tt> configuration
614 variable (see <a href="git-config.html">git-config(1)</a>).
615 The following parameters are available:
616 </p>
617 <div class="dlist"><dl>
618 <dt class="hdlist1">
619 <tt>changes</tt>
620 </dt>
621 <dd>
623 Compute the dirstat numbers by counting the lines that have been
624 removed from the source, or added to the destination. This ignores
625 the amount of pure code movements within a file. In other words,
626 rearranging lines in a file is not counted as much as other changes.
627 This is the default behavior when no parameter is given.
628 </p>
629 </dd>
630 <dt class="hdlist1">
631 <tt>lines</tt>
632 </dt>
633 <dd>
635 Compute the dirstat numbers by doing the regular line-based diff
636 analysis, and summing the removed/added line counts. (For binary
637 files, count 64-byte chunks instead, since binary files have no
638 natural concept of lines). This is a more expensive <tt>--dirstat</tt>
639 behavior than the <tt>changes</tt> behavior, but it does count rearranged
640 lines within a file as much as other changes. The resulting output
641 is consistent with what you get from the other <tt>--*stat</tt> options.
642 </p>
643 </dd>
644 <dt class="hdlist1">
645 <tt>files</tt>
646 </dt>
647 <dd>
649 Compute the dirstat numbers by counting the number of files changed.
650 Each changed file counts equally in the dirstat analysis. This is
651 the computationally cheapest <tt>--dirstat</tt> behavior, since it does
652 not have to look at the file contents at all.
653 </p>
654 </dd>
655 <dt class="hdlist1">
656 <tt>cumulative</tt>
657 </dt>
658 <dd>
660 Count changes in a child directory for the parent directory as well.
661 Note that when using <tt>cumulative</tt>, the sum of the percentages
662 reported may exceed 100%. The default (non-cumulative) behavior can
663 be specified with the <tt>noncumulative</tt> parameter.
664 </p>
665 </dd>
666 <dt class="hdlist1">
667 &lt;limit&gt;
668 </dt>
669 <dd>
671 An integer parameter specifies a cut-off percent (3% by default).
672 Directories contributing less than this percentage of the changes
673 are not shown in the output.
674 </p>
675 </dd>
676 </dl></div>
677 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
678 directories with less than 10% of the total amount of changed files,
679 and accumulating child directory counts in the parent directories:
680 <tt>--dirstat=files,10,cumulative</tt>.</p></div>
681 </dd>
682 <dt class="hdlist1">
683 --summary
684 </dt>
685 <dd>
687 Output a condensed summary of extended header information
688 such as creations, renames and mode changes.
689 </p>
690 </dd>
691 <dt class="hdlist1">
692 --patch-with-stat
693 </dt>
694 <dd>
696 Synonym for <tt>-p --stat</tt>.
697 </p>
698 </dd>
699 <dt class="hdlist1">
701 </dt>
702 <dd>
704 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
705 given, do not munge pathnames and use NULs as output field terminators.
706 </p>
707 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
708 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
709 respectively, and the pathname will be enclosed in double quotes if
710 any of those replacements occurred.</p></div>
711 </dd>
712 <dt class="hdlist1">
713 --name-only
714 </dt>
715 <dd>
717 Show only names of changed files.
718 </p>
719 </dd>
720 <dt class="hdlist1">
721 --name-status
722 </dt>
723 <dd>
725 Show only names and status of changed files. See the description
726 of the <tt>--diff-filter</tt> option on what the status letters mean.
727 </p>
728 </dd>
729 <dt class="hdlist1">
730 --submodule[=&lt;format&gt;]
731 </dt>
732 <dd>
734 Chose the output format for submodule differences. &lt;format&gt; can be one of
735 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
736 is used when this option is not given. <em>log</em> is the default value for this
737 option and lists the commits in that commit range like the <em>summary</em>
738 option of <a href="git-submodule.html">git-submodule(1)</a> does.
739 </p>
740 </dd>
741 <dt class="hdlist1">
742 --color[=&lt;when&gt;]
743 </dt>
744 <dd>
746 Show colored diff.
747 The value must be <tt>always</tt> (the default for <tt>&lt;when&gt;</tt>), <tt>never</tt>, or <tt>auto</tt>.
748 The default value is <tt>never</tt>.
749 It can be changed by the <tt>color.ui</tt> and <tt>color.diff</tt>
750 configuration settings.
751 </p>
752 </dd>
753 <dt class="hdlist1">
754 --no-color
755 </dt>
756 <dd>
758 Turn off colored diff.
759 This can be used to override configuration settings.
760 It is the same as <tt>--color=never</tt>.
761 </p>
762 </dd>
763 <dt class="hdlist1">
764 --word-diff[=&lt;mode&gt;]
765 </dt>
766 <dd>
768 Show a word diff, using the &lt;mode&gt; to delimit changed words.
769 By default, words are delimited by whitespace; see
770 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
771 must be one of:
772 </p>
773 <div class="dlist"><dl>
774 <dt class="hdlist1">
775 color
776 </dt>
777 <dd>
779 Highlight changed words using only colors. Implies <tt>--color</tt>.
780 </p>
781 </dd>
782 <dt class="hdlist1">
783 plain
784 </dt>
785 <dd>
787 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
788 attempts to escape the delimiters if they appear in the input,
789 so the output may be ambiguous.
790 </p>
791 </dd>
792 <dt class="hdlist1">
793 porcelain
794 </dt>
795 <dd>
797 Use a special line-based format intended for script
798 consumption. Added/removed/unchanged runs are printed in the
799 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
800 character at the beginning of the line and extending to the
801 end of the line. Newlines in the input are represented by a
802 tilde <tt>~</tt> on a line of its own.
803 </p>
804 </dd>
805 <dt class="hdlist1">
806 none
807 </dt>
808 <dd>
810 Disable word diff again.
811 </p>
812 </dd>
813 </dl></div>
814 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
815 highlight the changed parts in all modes if enabled.</p></div>
816 </dd>
817 <dt class="hdlist1">
818 --word-diff-regex=&lt;regex&gt;
819 </dt>
820 <dd>
822 Use &lt;regex&gt; to decide what a word is, instead of considering
823 runs of non-whitespace to be a word. Also implies
824 <tt>--word-diff</tt> unless it was already enabled.
825 </p>
826 <div class="paragraph"><p>Every non-overlapping match of the
827 &lt;regex&gt; is considered a word. Anything between these matches is
828 considered whitespace and ignored(!) for the purposes of finding
829 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
830 expression to make sure that it matches all non-whitespace characters.
831 A match that contains a newline is silently truncated(!) at the
832 newline.</p></div>
833 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
834 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
835 overrides any diff driver or configuration setting. Diff drivers
836 override configuration settings.</p></div>
837 </dd>
838 <dt class="hdlist1">
839 --color-words[=&lt;regex&gt;]
840 </dt>
841 <dd>
843 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
844 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
845 </p>
846 </dd>
847 <dt class="hdlist1">
848 --no-renames
849 </dt>
850 <dd>
852 Turn off rename detection, even when the configuration
853 file gives the default to do so.
854 </p>
855 </dd>
856 <dt class="hdlist1">
857 --check
858 </dt>
859 <dd>
861 Warn if changes introduce trailing whitespace
862 or an indent that uses a space before a tab. Exits with
863 non-zero status if problems are found. Not compatible with
864 --exit-code.
865 </p>
866 </dd>
867 <dt class="hdlist1">
868 --full-index
869 </dt>
870 <dd>
872 Instead of the first handful of characters, show the full
873 pre- and post-image blob object names on the "index"
874 line when generating patch format output.
875 </p>
876 </dd>
877 <dt class="hdlist1">
878 --binary
879 </dt>
880 <dd>
882 In addition to <tt>--full-index</tt>, output a binary diff that
883 can be applied with <tt>git-apply</tt>.
884 </p>
885 </dd>
886 <dt class="hdlist1">
887 --abbrev[=&lt;n&gt;]
888 </dt>
889 <dd>
891 Instead of showing the full 40-byte hexadecimal object
892 name in diff-raw format output and diff-tree header
893 lines, show only a partial prefix. This is
894 independent of the <tt>--full-index</tt> option above, which controls
895 the diff-patch output format. Non default number of
896 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
897 </p>
898 </dd>
899 <dt class="hdlist1">
900 -B[&lt;n&gt;][/&lt;m&gt;]
901 </dt>
902 <dt class="hdlist1">
903 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
904 </dt>
905 <dd>
907 Break complete rewrite changes into pairs of delete and
908 create. This serves two purposes:
909 </p>
910 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
911 not as a series of deletion and insertion mixed together with a very
912 few lines that happen to match textually as the context, but as a
913 single deletion of everything old followed by a single insertion of
914 everything new, and the number <tt>m</tt> controls this aspect of the -B
915 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
916 original should remain in the result for git to consider it a total
917 rewrite (i.e. otherwise the resulting patch will be a series of
918 deletion and insertion mixed together with context lines).</p></div>
919 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
920 source of a rename (usually -M only considers a file that disappeared
921 as the source of a rename), and the number <tt>n</tt> controls this aspect of
922 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
923 addition and deletion compared to 20% or more of the file&#8217;s size are
924 eligible for being picked up as a possible source of a rename to
925 another file.</p></div>
926 </dd>
927 <dt class="hdlist1">
928 -M[&lt;n&gt;]
929 </dt>
930 <dt class="hdlist1">
931 --find-renames[=&lt;n&gt;]
932 </dt>
933 <dd>
935 Detect renames.
936 If <tt>n</tt> is specified, it is a threshold on the similarity
937 index (i.e. amount of addition/deletions compared to the
938 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
939 delete/add pair to be a rename if more than 90% of the file
940 hasn&#8217;t changed.
941 </p>
942 </dd>
943 <dt class="hdlist1">
944 -C[&lt;n&gt;]
945 </dt>
946 <dt class="hdlist1">
947 --find-copies[=&lt;n&gt;]
948 </dt>
949 <dd>
951 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
952 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
953 </p>
954 </dd>
955 <dt class="hdlist1">
956 --find-copies-harder
957 </dt>
958 <dd>
960 For performance reasons, by default, <tt>-C</tt> option finds copies only
961 if the original file of the copy was modified in the same
962 changeset. This flag makes the command
963 inspect unmodified files as candidates for the source of
964 copy. This is a very expensive operation for large
965 projects, so use it with caution. Giving more than one
966 <tt>-C</tt> option has the same effect.
967 </p>
968 </dd>
969 <dt class="hdlist1">
971 </dt>
972 <dt class="hdlist1">
973 --irreversible-delete
974 </dt>
975 <dd>
977 Omit the preimage for deletes, i.e. print only the header but not
978 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
979 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
980 solely for people who want to just concentrate on reviewing the
981 text after the change. In addition, the output obviously lack
982 enough information to apply such a patch in reverse, even manually,
983 hence the name of the option.
984 </p>
985 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
986 of a delete/create pair.</p></div>
987 </dd>
988 <dt class="hdlist1">
989 -l&lt;num&gt;
990 </dt>
991 <dd>
993 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
994 is the number of potential rename/copy targets. This
995 option prevents rename/copy detection from running if
996 the number of rename/copy targets exceeds the specified
997 number.
998 </p>
999 </dd>
1000 <dt class="hdlist1">
1001 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
1002 </dt>
1003 <dd>
1005 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
1006 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
1007 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
1008 are Unmerged (<tt>U</tt>), are
1009 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
1010 Any combination of the filter characters (including none) can be used.
1011 When <tt>*</tt> (All-or-none) is added to the combination, all
1012 paths are selected if there is any file that matches
1013 other criteria in the comparison; if there is no file
1014 that matches other criteria, nothing is selected.
1015 </p>
1016 </dd>
1017 <dt class="hdlist1">
1018 -S&lt;string&gt;
1019 </dt>
1020 <dd>
1022 Look for differences that introduce or remove an instance of
1023 &lt;string&gt;. Note that this is different than the string simply
1024 appearing in diff output; see the <em>pickaxe</em> entry in
1025 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
1026 </p>
1027 </dd>
1028 <dt class="hdlist1">
1029 -G&lt;regex&gt;
1030 </dt>
1031 <dd>
1033 Look for differences whose added or removed line matches
1034 the given &lt;regex&gt;.
1035 </p>
1036 </dd>
1037 <dt class="hdlist1">
1038 --pickaxe-all
1039 </dt>
1040 <dd>
1042 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
1043 changeset, not just the files that contain the change
1044 in &lt;string&gt;.
1045 </p>
1046 </dd>
1047 <dt class="hdlist1">
1048 --pickaxe-regex
1049 </dt>
1050 <dd>
1052 Make the &lt;string&gt; not a plain string but an extended POSIX
1053 regex to match.
1054 </p>
1055 </dd>
1056 <dt class="hdlist1">
1057 -O&lt;orderfile&gt;
1058 </dt>
1059 <dd>
1061 Output the patch in the order specified in the
1062 &lt;orderfile&gt;, which has one shell glob pattern per line.
1063 </p>
1064 </dd>
1065 <dt class="hdlist1">
1067 </dt>
1068 <dd>
1070 Swap two inputs; that is, show differences from index or
1071 on-disk file to tree contents.
1072 </p>
1073 </dd>
1074 <dt class="hdlist1">
1075 --relative[=&lt;path&gt;]
1076 </dt>
1077 <dd>
1079 When run from a subdirectory of the project, it can be
1080 told to exclude changes outside the directory and show
1081 pathnames relative to it with this option. When you are
1082 not in a subdirectory (e.g. in a bare repository), you
1083 can name which subdirectory to make the output relative
1084 to by giving a &lt;path&gt; as an argument.
1085 </p>
1086 </dd>
1087 <dt class="hdlist1">
1089 </dt>
1090 <dt class="hdlist1">
1091 --text
1092 </dt>
1093 <dd>
1095 Treat all files as text.
1096 </p>
1097 </dd>
1098 <dt class="hdlist1">
1099 --ignore-space-at-eol
1100 </dt>
1101 <dd>
1103 Ignore changes in whitespace at EOL.
1104 </p>
1105 </dd>
1106 <dt class="hdlist1">
1108 </dt>
1109 <dt class="hdlist1">
1110 --ignore-space-change
1111 </dt>
1112 <dd>
1114 Ignore changes in amount of whitespace. This ignores whitespace
1115 at line end, and considers all other sequences of one or
1116 more whitespace characters to be equivalent.
1117 </p>
1118 </dd>
1119 <dt class="hdlist1">
1121 </dt>
1122 <dt class="hdlist1">
1123 --ignore-all-space
1124 </dt>
1125 <dd>
1127 Ignore whitespace when comparing lines. This ignores
1128 differences even if one line has whitespace where the other
1129 line has none.
1130 </p>
1131 </dd>
1132 <dt class="hdlist1">
1133 --inter-hunk-context=&lt;lines&gt;
1134 </dt>
1135 <dd>
1137 Show the context between diff hunks, up to the specified number
1138 of lines, thereby fusing hunks that are close to each other.
1139 </p>
1140 </dd>
1141 <dt class="hdlist1">
1142 --exit-code
1143 </dt>
1144 <dd>
1146 Make the program exit with codes similar to diff(1).
1147 That is, it exits with 1 if there were differences and
1148 0 means no differences.
1149 </p>
1150 </dd>
1151 <dt class="hdlist1">
1152 --quiet
1153 </dt>
1154 <dd>
1156 Disable all output of the program. Implies <tt>--exit-code</tt>.
1157 </p>
1158 </dd>
1159 <dt class="hdlist1">
1160 --ext-diff
1161 </dt>
1162 <dd>
1164 Allow an external diff helper to be executed. If you set an
1165 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1166 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1167 </p>
1168 </dd>
1169 <dt class="hdlist1">
1170 --no-ext-diff
1171 </dt>
1172 <dd>
1174 Disallow external diff drivers.
1175 </p>
1176 </dd>
1177 <dt class="hdlist1">
1178 --ignore-submodules[=&lt;when&gt;]
1179 </dt>
1180 <dd>
1182 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1183 either "none", "untracked", "dirty" or "all", which is the default
1184 Using "none" will consider the submodule modified when it either contains
1185 untracked or modified files or its HEAD differs from the commit recorded
1186 in the superproject and can be used to override any settings of the
1187 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1188 "untracked" is used submodules are not considered dirty when they only
1189 contain untracked content (but they are still scanned for modified
1190 content). Using "dirty" ignores all changes to the work tree of submodules,
1191 only changes to the commits stored in the superproject are shown (this was
1192 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1193 </p>
1194 </dd>
1195 <dt class="hdlist1">
1196 --src-prefix=&lt;prefix&gt;
1197 </dt>
1198 <dd>
1200 Show the given source prefix instead of "a/".
1201 </p>
1202 </dd>
1203 <dt class="hdlist1">
1204 --dst-prefix=&lt;prefix&gt;
1205 </dt>
1206 <dd>
1208 Show the given destination prefix instead of "b/".
1209 </p>
1210 </dd>
1211 <dt class="hdlist1">
1212 --no-prefix
1213 </dt>
1214 <dd>
1216 Do not show any source or destination prefix.
1217 </p>
1218 </dd>
1219 </dl></div>
1220 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1221 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1222 <div class="dlist"><dl>
1223 <dt class="hdlist1">
1224 &lt;path&gt;&#8230;
1225 </dt>
1226 <dd>
1228 The &lt;paths&gt; parameters, when given, are used to limit
1229 the diff to the named paths (you can give directory
1230 names and get diff for all files under them).
1231 </p>
1232 </dd>
1233 </dl></div>
1234 </div>
1235 <h2 id="_raw_output_format">Raw output format</h2>
1236 <div class="sectionbody">
1237 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1238 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1239 <div class="paragraph"><p>These commands all compare two sets of things; what is
1240 compared differs:</p></div>
1241 <div class="dlist"><dl>
1242 <dt class="hdlist1">
1243 git-diff-index &lt;tree-ish&gt;
1244 </dt>
1245 <dd>
1247 compares the &lt;tree-ish&gt; and the files on the filesystem.
1248 </p>
1249 </dd>
1250 <dt class="hdlist1">
1251 git-diff-index --cached &lt;tree-ish&gt;
1252 </dt>
1253 <dd>
1255 compares the &lt;tree-ish&gt; and the index.
1256 </p>
1257 </dd>
1258 <dt class="hdlist1">
1259 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1260 </dt>
1261 <dd>
1263 compares the trees named by the two arguments.
1264 </p>
1265 </dd>
1266 <dt class="hdlist1">
1267 git-diff-files [&lt;pattern&gt;&#8230;]
1268 </dt>
1269 <dd>
1271 compares the index and the files on the filesystem.
1272 </p>
1273 </dd>
1274 </dl></div>
1275 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1276 what is being compared. After that, all the commands print one output
1277 line per changed file.</p></div>
1278 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1279 <div class="listingblock">
1280 <div class="content">
1281 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1282 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1283 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1284 create :000000 100644 0000000... 1234567... A file4
1285 delete :100644 000000 1234567... 0000000... D file5
1286 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1287 </div></div>
1288 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1289 <div class="olist arabic"><ol class="arabic">
1290 <li>
1292 a colon.
1293 </p>
1294 </li>
1295 <li>
1297 mode for "src"; 000000 if creation or unmerged.
1298 </p>
1299 </li>
1300 <li>
1302 a space.
1303 </p>
1304 </li>
1305 <li>
1307 mode for "dst"; 000000 if deletion or unmerged.
1308 </p>
1309 </li>
1310 <li>
1312 a space.
1313 </p>
1314 </li>
1315 <li>
1317 sha1 for "src"; 0{40} if creation or unmerged.
1318 </p>
1319 </li>
1320 <li>
1322 a space.
1323 </p>
1324 </li>
1325 <li>
1327 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1328 </p>
1329 </li>
1330 <li>
1332 a space.
1333 </p>
1334 </li>
1335 <li>
1337 status, followed by optional "score" number.
1338 </p>
1339 </li>
1340 <li>
1342 a tab or a NUL when <em>-z</em> option is used.
1343 </p>
1344 </li>
1345 <li>
1347 path for "src"
1348 </p>
1349 </li>
1350 <li>
1352 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1353 </p>
1354 </li>
1355 <li>
1357 path for "dst"; only exists for C or R.
1358 </p>
1359 </li>
1360 <li>
1362 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1363 </p>
1364 </li>
1365 </ol></div>
1366 <div class="paragraph"><p>Possible status letters are:</p></div>
1367 <div class="ulist"><ul>
1368 <li>
1370 A: addition of a file
1371 </p>
1372 </li>
1373 <li>
1375 C: copy of a file into a new one
1376 </p>
1377 </li>
1378 <li>
1380 D: deletion of a file
1381 </p>
1382 </li>
1383 <li>
1385 M: modification of the contents or mode of a file
1386 </p>
1387 </li>
1388 <li>
1390 R: renaming of a file
1391 </p>
1392 </li>
1393 <li>
1395 T: change in the type of the file
1396 </p>
1397 </li>
1398 <li>
1400 U: file is unmerged (you must complete the merge before it can
1401 be committed)
1402 </p>
1403 </li>
1404 <li>
1406 X: "unknown" change type (most probably a bug, please report it)
1407 </p>
1408 </li>
1409 </ul></div>
1410 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1411 percentage of similarity between the source and target of the move or
1412 copy), and are the only ones to be so.</p></div>
1413 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1414 and it is out of sync with the index.</p></div>
1415 <div class="paragraph"><p>Example:</p></div>
1416 <div class="listingblock">
1417 <div class="content">
1418 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1419 </div></div>
1420 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1421 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1422 respectively.</p></div>
1423 </div>
1424 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1425 <div class="sectionbody">
1426 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1427 can take <em>-c</em> or <em>--cc</em> option
1428 to generate diff output also for merge commits. The output differs
1429 from the format described above in the following way:</p></div>
1430 <div class="olist arabic"><ol class="arabic">
1431 <li>
1433 there is a colon for each parent
1434 </p>
1435 </li>
1436 <li>
1438 there are more "src" modes and "src" sha1
1439 </p>
1440 </li>
1441 <li>
1443 status is concatenated status characters for each parent
1444 </p>
1445 </li>
1446 <li>
1448 no optional "score" number
1449 </p>
1450 </li>
1451 <li>
1453 single path, only for "dst"
1454 </p>
1455 </li>
1456 </ol></div>
1457 <div class="paragraph"><p>Example:</p></div>
1458 <div class="listingblock">
1459 <div class="content">
1460 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1461 </div></div>
1462 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1463 all parents.</p></div>
1464 </div>
1465 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1466 <div class="sectionbody">
1467 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1468 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1469 "git log" with the "-p" option, they
1470 do not produce the output described above; instead they produce a
1471 patch file. You can customize the creation of such patches via the
1472 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1473 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1474 diff format:</p></div>
1475 <div class="olist arabic"><ol class="arabic">
1476 <li>
1478 It is preceded with a "git diff" header that looks like this:
1479 </p>
1480 <div class="literalblock">
1481 <div class="content">
1482 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1483 </div></div>
1484 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1485 involved. Especially, even for a creation or a deletion,
1486 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1487 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1488 name of the source file of the rename/copy and the name of
1489 the file that rename/copy produces, respectively.</p></div>
1490 </li>
1491 <li>
1493 It is followed by one or more extended header lines:
1494 </p>
1495 <div class="literalblock">
1496 <div class="content">
1497 <pre><tt>old mode &lt;mode&gt;
1498 new mode &lt;mode&gt;
1499 deleted file mode &lt;mode&gt;
1500 new file mode &lt;mode&gt;
1501 copy from &lt;path&gt;
1502 copy to &lt;path&gt;
1503 rename from &lt;path&gt;
1504 rename to &lt;path&gt;
1505 similarity index &lt;number&gt;
1506 dissimilarity index &lt;number&gt;
1507 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1508 </div></div>
1509 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1510 and file permission bits.</p></div>
1511 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1512 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1513 the dissimilarity index is the percentage of changed lines. It
1514 is a rounded down integer, followed by a percent sign. The
1515 similarity index value of 100% is thus reserved for two equal
1516 files, while 100% dissimilarity means that no line from the old
1517 file made it into the new one.</p></div>
1518 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1519 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1520 separate lines indicate the old and the new mode.</p></div>
1521 </li>
1522 <li>
1524 TAB, LF, double quote and backslash characters in pathnames
1525 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1526 If there is need for such substitution then the whole
1527 pathname is put in double quotes.
1528 </p>
1529 </li>
1530 <li>
1532 All the <tt>file1</tt> files in the output refer to files before the
1533 commit, and all the <tt>file2</tt> files refer to files after the commit.
1534 It is incorrect to apply each change to each file sequentially. For
1535 example, this patch will swap a and b:
1536 </p>
1537 <div class="literalblock">
1538 <div class="content">
1539 <pre><tt>diff --git a/a b/b
1540 rename from a
1541 rename to b
1542 diff --git a/b b/a
1543 rename from b
1544 rename to a</tt></pre>
1545 </div></div>
1546 </li>
1547 </ol></div>
1548 </div>
1549 <h2 id="_combined_diff_format">combined diff format</h2>
1550 <div class="sectionbody">
1551 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1552 produce a <em>combined diff</em> when showing a merge. This is the default
1553 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1554 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1555 of these commands to force generation of diffs with individual parents
1556 of a merge.</p></div>
1557 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1558 <div class="listingblock">
1559 <div class="content">
1560 <pre><tt>diff --combined describe.c
1561 index fabadb8,cc95eb0..4866510
1562 --- a/describe.c
1563 +++ b/describe.c
1564 @@@ -98,20 -98,12 +98,20 @@@
1565 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1568 - static void describe(char *arg)
1569 -static void describe(struct commit *cmit, int last_one)
1570 ++static void describe(char *arg, int last_one)
1572 + unsigned char sha1[20];
1573 + struct commit *cmit;
1574 struct commit_list *list;
1575 static int initialized = 0;
1576 struct commit_name *n;
1578 + if (get_sha1(arg, sha1) &lt; 0)
1579 + usage(describe_usage);
1580 + cmit = lookup_commit_reference(sha1);
1581 + if (!cmit)
1582 + usage(describe_usage);
1584 if (!initialized) {
1585 initialized = 1;
1586 for_each_ref(get_name);</tt></pre>
1587 </div></div>
1588 <div class="olist arabic"><ol class="arabic">
1589 <li>
1591 It is preceded with a "git diff" header, that looks like
1592 this (when <em>-c</em> option is used):
1593 </p>
1594 <div class="literalblock">
1595 <div class="content">
1596 <pre><tt>diff --combined file</tt></pre>
1597 </div></div>
1598 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1599 <div class="literalblock">
1600 <div class="content">
1601 <pre><tt>diff --cc file</tt></pre>
1602 </div></div>
1603 </li>
1604 <li>
1606 It is followed by one or more extended header lines
1607 (this example shows a merge with two parents):
1608 </p>
1609 <div class="literalblock">
1610 <div class="content">
1611 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1612 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1613 new file mode &lt;mode&gt;
1614 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1615 </div></div>
1616 <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
1617 the &lt;mode&gt; is different from the rest. Extended headers with
1618 information about detected contents movement (renames and
1619 copying detection) are designed to work with diff of two
1620 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1621 </li>
1622 <li>
1624 It is followed by two-line from-file/to-file header
1625 </p>
1626 <div class="literalblock">
1627 <div class="content">
1628 <pre><tt>--- a/file
1629 +++ b/file</tt></pre>
1630 </div></div>
1631 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1632 format, <tt>/dev/null</tt> is used to signal created or deleted
1633 files.</p></div>
1634 </li>
1635 <li>
1637 Chunk header format is modified to prevent people from
1638 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1639 was created for review of merge commit changes, and was not
1640 meant for apply. The change is similar to the change in the
1641 extended <em>index</em> header:
1642 </p>
1643 <div class="literalblock">
1644 <div class="content">
1645 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1646 </div></div>
1647 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1648 header for combined diff format.</p></div>
1649 </li>
1650 </ol></div>
1651 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1652 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
1653 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1654 compares two or more files file1, file2,&#8230; with one file X, and
1655 shows how X differs from each of fileN. One column for each of
1656 fileN is prepended to the output line to note how X&#8217;s line is
1657 different from it.</p></div>
1658 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1659 fileN but it does not appear in the result. A <tt>+</tt> character
1660 in the column N means that the line appears in the result,
1661 and fileN does not have that line (in other words, the line was
1662 added, from the point of view of that parent).</p></div>
1663 <div class="paragraph"><p>In the above example output, the function signature was changed
1664 from both files (hence two <tt>-</tt> removals from both file1 and
1665 file2, plus <tt>++</tt> to mean one line that was added does not appear
1666 in either file1 nor file2). Also eight other lines are the same
1667 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1668 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1669 merge commit with the merge result (i.e. file1..fileN are the
1670 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1671 two unresolved merge parents with the working tree file
1672 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1673 "their version").</p></div>
1674 </div>
1675 <h2 id="_other_diff_formats">other diff formats</h2>
1676 <div class="sectionbody">
1677 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1678 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1679 output. These options can be combined with other options, such as
1680 <tt>-p</tt>, and are meant for human consumption.</p></div>
1681 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1682 formats the pathnames compactly by combining common prefix and suffix of
1683 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1684 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1685 <div class="listingblock">
1686 <div class="content">
1687 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1688 </div></div>
1689 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1690 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1691 like this:</p></div>
1692 <div class="listingblock">
1693 <div class="content">
1694 <pre><tt>1 2 README
1695 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1696 </div></div>
1697 <div class="paragraph"><p>That is, from left to right:</p></div>
1698 <div class="olist arabic"><ol class="arabic">
1699 <li>
1701 the number of added lines;
1702 </p>
1703 </li>
1704 <li>
1706 a tab;
1707 </p>
1708 </li>
1709 <li>
1711 the number of deleted lines;
1712 </p>
1713 </li>
1714 <li>
1716 a tab;
1717 </p>
1718 </li>
1719 <li>
1721 pathname (possibly with rename/copy information);
1722 </p>
1723 </li>
1724 <li>
1726 a newline.
1727 </p>
1728 </li>
1729 </ol></div>
1730 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1731 <div class="listingblock">
1732 <div class="content">
1733 <pre><tt>1 2 README NUL
1734 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1735 </div></div>
1736 <div class="paragraph"><p>That is:</p></div>
1737 <div class="olist arabic"><ol class="arabic">
1738 <li>
1740 the number of added lines;
1741 </p>
1742 </li>
1743 <li>
1745 a tab;
1746 </p>
1747 </li>
1748 <li>
1750 the number of deleted lines;
1751 </p>
1752 </li>
1753 <li>
1755 a tab;
1756 </p>
1757 </li>
1758 <li>
1760 a NUL (only exists if renamed/copied);
1761 </p>
1762 </li>
1763 <li>
1765 pathname in preimage;
1766 </p>
1767 </li>
1768 <li>
1770 a NUL (only exists if renamed/copied);
1771 </p>
1772 </li>
1773 <li>
1775 pathname in postimage (only exists if renamed/copied);
1776 </p>
1777 </li>
1778 <li>
1780 a NUL.
1781 </p>
1782 </li>
1783 </ol></div>
1784 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1785 scripts that read the output to tell if the current record being read is
1786 a single-path record or a rename/copy record without reading ahead.
1787 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1788 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1789 </div>
1790 <h2 id="_examples">EXAMPLES</h2>
1791 <div class="sectionbody">
1792 <div class="dlist"><dl>
1793 <dt class="hdlist1">
1794 Various ways to check your working tree
1795 </dt>
1796 <dd>
1797 <div class="listingblock">
1798 <div class="content">
1799 <pre><tt>$ git diff <b>&lt;1&gt;</b>
1800 $ git diff --cached <b>&lt;2&gt;</b>
1801 $ git diff HEAD <b>&lt;3&gt;</b></tt></pre>
1802 </div></div>
1803 <div class="colist arabic"><ol>
1804 <li>
1806 Changes in the working tree not yet staged for the next commit.
1807 </p>
1808 </li>
1809 <li>
1811 Changes between the index and your last commit; what you
1812 would be committing if you run "git commit" without "-a" option.
1813 </p>
1814 </li>
1815 <li>
1817 Changes in the working tree since your last commit; what you
1818 would be committing if you run "git commit -a"
1819 </p>
1820 </li>
1821 </ol></div>
1822 </dd>
1823 <dt class="hdlist1">
1824 Comparing with arbitrary commits
1825 </dt>
1826 <dd>
1827 <div class="listingblock">
1828 <div class="content">
1829 <pre><tt>$ git diff test <b>&lt;1&gt;</b>
1830 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
1831 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></tt></pre>
1832 </div></div>
1833 <div class="colist arabic"><ol>
1834 <li>
1836 Instead of using the tip of the current branch, compare with the
1837 tip of "test" branch.
1838 </p>
1839 </li>
1840 <li>
1842 Instead of comparing with the tip of "test" branch, compare with
1843 the tip of the current branch, but limit the comparison to the
1844 file "test".
1845 </p>
1846 </li>
1847 <li>
1849 Compare the version before the last commit and the last commit.
1850 </p>
1851 </li>
1852 </ol></div>
1853 </dd>
1854 <dt class="hdlist1">
1855 Comparing branches
1856 </dt>
1857 <dd>
1858 <div class="listingblock">
1859 <div class="content">
1860 <pre><tt>$ git diff topic master <b>&lt;1&gt;</b>
1861 $ git diff topic..master <b>&lt;2&gt;</b>
1862 $ git diff topic...master <b>&lt;3&gt;</b></tt></pre>
1863 </div></div>
1864 <div class="colist arabic"><ol>
1865 <li>
1867 Changes between the tips of the topic and the master branches.
1868 </p>
1869 </li>
1870 <li>
1872 Same as above.
1873 </p>
1874 </li>
1875 <li>
1877 Changes that occurred on the master branch since when the topic
1878 branch was started off it.
1879 </p>
1880 </li>
1881 </ol></div>
1882 </dd>
1883 <dt class="hdlist1">
1884 Limiting the diff output
1885 </dt>
1886 <dd>
1887 <div class="listingblock">
1888 <div class="content">
1889 <pre><tt>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
1890 $ git diff --name-status <b>&lt;2&gt;</b>
1891 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></tt></pre>
1892 </div></div>
1893 <div class="colist arabic"><ol>
1894 <li>
1896 Show only modification, rename and copy, but not addition
1897 nor deletion.
1898 </p>
1899 </li>
1900 <li>
1902 Show only names and the nature of change, but not actual
1903 diff output.
1904 </p>
1905 </li>
1906 <li>
1908 Limit diff output to named subtrees.
1909 </p>
1910 </li>
1911 </ol></div>
1912 </dd>
1913 <dt class="hdlist1">
1914 Munging the diff output
1915 </dt>
1916 <dd>
1917 <div class="listingblock">
1918 <div class="content">
1919 <pre><tt>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
1920 $ git diff -R <b>&lt;2&gt;</b></tt></pre>
1921 </div></div>
1922 <div class="colist arabic"><ol>
1923 <li>
1925 Spend extra cycles to find renames, copies and complete
1926 rewrites (very expensive).
1927 </p>
1928 </li>
1929 <li>
1931 Output diff in reverse.
1932 </p>
1933 </li>
1934 </ol></div>
1935 </dd>
1936 </dl></div>
1937 </div>
1938 <h2 id="_see_also">SEE ALSO</h2>
1939 <div class="sectionbody">
1940 <div class="paragraph"><p>diff(1),
1941 <a href="git-difftool.html">git-difftool(1)</a>,
1942 <a href="git-log.html">git-log(1)</a>,
1943 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
1944 <a href="git-format-patch.html">git-format-patch(1)</a>,
1945 <a href="git-apply.html">git-apply(1)</a></p></div>
1946 </div>
1947 <h2 id="_git">GIT</h2>
1948 <div class="sectionbody">
1949 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1950 </div>
1951 <div id="footer">
1952 <div id="footer-text">
1953 Last updated 2011-03-15 23:30:13 UTC
1954 </div>
1955 </div>
1956 </body>
1957 </html>