Autogenerated HTML docs for v1.7.5-185-g0b9dee
[git/jnareb-git.git] / git-diff.html
blob23cb5d0f86e69ecb27bbeb787d727e6267a30a7d
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;limit&gt;]
607 </dt>
608 <dd>
610 Output the distribution of relative amount of changes (number of lines added or
611 removed) for each sub-directory. Directories with changes below
612 a cut-off percent (3% by default) are not shown. The cut-off percent
613 can be set with <tt>--dirstat=&lt;limit&gt;</tt>. Changes in a child directory are not
614 counted for the parent directory, unless <tt>--cumulative</tt> is used.
615 </p>
616 <div class="paragraph"><p>Note that the <tt>--dirstat</tt> option computes the changes while ignoring
617 the amount of pure code movements within a file. In other words,
618 rearranging lines in a file is not counted as much as other changes.</p></div>
619 </dd>
620 <dt class="hdlist1">
621 --dirstat-by-file[=&lt;limit&gt;]
622 </dt>
623 <dd>
625 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
626 </p>
627 </dd>
628 <dt class="hdlist1">
629 --summary
630 </dt>
631 <dd>
633 Output a condensed summary of extended header information
634 such as creations, renames and mode changes.
635 </p>
636 </dd>
637 <dt class="hdlist1">
638 --patch-with-stat
639 </dt>
640 <dd>
642 Synonym for <tt>-p --stat</tt>.
643 </p>
644 </dd>
645 <dt class="hdlist1">
647 </dt>
648 <dd>
650 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
651 given, do not munge pathnames and use NULs as output field terminators.
652 </p>
653 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
654 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
655 respectively, and the pathname will be enclosed in double quotes if
656 any of those replacements occurred.</p></div>
657 </dd>
658 <dt class="hdlist1">
659 --name-only
660 </dt>
661 <dd>
663 Show only names of changed files.
664 </p>
665 </dd>
666 <dt class="hdlist1">
667 --name-status
668 </dt>
669 <dd>
671 Show only names and status of changed files. See the description
672 of the <tt>--diff-filter</tt> option on what the status letters mean.
673 </p>
674 </dd>
675 <dt class="hdlist1">
676 --submodule[=&lt;format&gt;]
677 </dt>
678 <dd>
680 Chose the output format for submodule differences. &lt;format&gt; can be one of
681 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
682 is used when this option is not given. <em>log</em> is the default value for this
683 option and lists the commits in that commit range like the <em>summary</em>
684 option of <a href="git-submodule.html">git-submodule(1)</a> does.
685 </p>
686 </dd>
687 <dt class="hdlist1">
688 --color[=&lt;when&gt;]
689 </dt>
690 <dd>
692 Show colored diff.
693 The value must be always (the default), never, or auto.
694 </p>
695 </dd>
696 <dt class="hdlist1">
697 --no-color
698 </dt>
699 <dd>
701 Turn off colored diff, even when the configuration file
702 gives the default to color output.
703 Same as <tt>--color=never</tt>.
704 </p>
705 </dd>
706 <dt class="hdlist1">
707 --word-diff[=&lt;mode&gt;]
708 </dt>
709 <dd>
711 Show a word diff, using the &lt;mode&gt; to delimit changed words.
712 By default, words are delimited by whitespace; see
713 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
714 must be one of:
715 </p>
716 <div class="dlist"><dl>
717 <dt class="hdlist1">
718 color
719 </dt>
720 <dd>
722 Highlight changed words using only colors. Implies <tt>--color</tt>.
723 </p>
724 </dd>
725 <dt class="hdlist1">
726 plain
727 </dt>
728 <dd>
730 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
731 attempts to escape the delimiters if they appear in the input,
732 so the output may be ambiguous.
733 </p>
734 </dd>
735 <dt class="hdlist1">
736 porcelain
737 </dt>
738 <dd>
740 Use a special line-based format intended for script
741 consumption. Added/removed/unchanged runs are printed in the
742 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
743 character at the beginning of the line and extending to the
744 end of the line. Newlines in the input are represented by a
745 tilde <tt>~</tt> on a line of its own.
746 </p>
747 </dd>
748 <dt class="hdlist1">
749 none
750 </dt>
751 <dd>
753 Disable word diff again.
754 </p>
755 </dd>
756 </dl></div>
757 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
758 highlight the changed parts in all modes if enabled.</p></div>
759 </dd>
760 <dt class="hdlist1">
761 --word-diff-regex=&lt;regex&gt;
762 </dt>
763 <dd>
765 Use &lt;regex&gt; to decide what a word is, instead of considering
766 runs of non-whitespace to be a word. Also implies
767 <tt>--word-diff</tt> unless it was already enabled.
768 </p>
769 <div class="paragraph"><p>Every non-overlapping match of the
770 &lt;regex&gt; is considered a word. Anything between these matches is
771 considered whitespace and ignored(!) for the purposes of finding
772 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
773 expression to make sure that it matches all non-whitespace characters.
774 A match that contains a newline is silently truncated(!) at the
775 newline.</p></div>
776 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
777 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
778 overrides any diff driver or configuration setting. Diff drivers
779 override configuration settings.</p></div>
780 </dd>
781 <dt class="hdlist1">
782 --color-words[=&lt;regex&gt;]
783 </dt>
784 <dd>
786 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
787 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
788 </p>
789 </dd>
790 <dt class="hdlist1">
791 --no-renames
792 </dt>
793 <dd>
795 Turn off rename detection, even when the configuration
796 file gives the default to do so.
797 </p>
798 </dd>
799 <dt class="hdlist1">
800 --check
801 </dt>
802 <dd>
804 Warn if changes introduce trailing whitespace
805 or an indent that uses a space before a tab. Exits with
806 non-zero status if problems are found. Not compatible with
807 --exit-code.
808 </p>
809 </dd>
810 <dt class="hdlist1">
811 --full-index
812 </dt>
813 <dd>
815 Instead of the first handful of characters, show the full
816 pre- and post-image blob object names on the "index"
817 line when generating patch format output.
818 </p>
819 </dd>
820 <dt class="hdlist1">
821 --binary
822 </dt>
823 <dd>
825 In addition to <tt>--full-index</tt>, output a binary diff that
826 can be applied with <tt>git-apply</tt>.
827 </p>
828 </dd>
829 <dt class="hdlist1">
830 --abbrev[=&lt;n&gt;]
831 </dt>
832 <dd>
834 Instead of showing the full 40-byte hexadecimal object
835 name in diff-raw format output and diff-tree header
836 lines, show only a partial prefix. This is
837 independent of the <tt>--full-index</tt> option above, which controls
838 the diff-patch output format. Non default number of
839 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
840 </p>
841 </dd>
842 <dt class="hdlist1">
843 -B[&lt;n&gt;][/&lt;m&gt;]
844 </dt>
845 <dt class="hdlist1">
846 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
847 </dt>
848 <dd>
850 Break complete rewrite changes into pairs of delete and
851 create. This serves two purposes:
852 </p>
853 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
854 not as a series of deletion and insertion mixed together with a very
855 few lines that happen to match textually as the context, but as a
856 single deletion of everything old followed by a single insertion of
857 everything new, and the number <tt>m</tt> controls this aspect of the -B
858 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
859 original should remain in the result for git to consider it a total
860 rewrite (i.e. otherwise the resulting patch will be a series of
861 deletion and insertion mixed together with context lines).</p></div>
862 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
863 source of a rename (usually -M only considers a file that disappeared
864 as the source of a rename), and the number <tt>n</tt> controls this aspect of
865 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
866 addition and deletion compared to 20% or more of the file&#8217;s size are
867 eligible for being picked up as a possible source of a rename to
868 another file.</p></div>
869 </dd>
870 <dt class="hdlist1">
871 -M[&lt;n&gt;]
872 </dt>
873 <dt class="hdlist1">
874 --find-renames[=&lt;n&gt;]
875 </dt>
876 <dd>
878 Detect renames.
879 If <tt>n</tt> is specified, it is a is a threshold on the similarity
880 index (i.e. amount of addition/deletions compared to the
881 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
882 delete/add pair to be a rename if more than 90% of the file
883 hasn&#8217;t changed.
884 </p>
885 </dd>
886 <dt class="hdlist1">
887 -C[&lt;n&gt;]
888 </dt>
889 <dt class="hdlist1">
890 --find-copies[=&lt;n&gt;]
891 </dt>
892 <dd>
894 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
895 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
896 </p>
897 </dd>
898 <dt class="hdlist1">
899 --find-copies-harder
900 </dt>
901 <dd>
903 For performance reasons, by default, <tt>-C</tt> option finds copies only
904 if the original file of the copy was modified in the same
905 changeset. This flag makes the command
906 inspect unmodified files as candidates for the source of
907 copy. This is a very expensive operation for large
908 projects, so use it with caution. Giving more than one
909 <tt>-C</tt> option has the same effect.
910 </p>
911 </dd>
912 <dt class="hdlist1">
914 </dt>
915 <dt class="hdlist1">
916 --irreversible-delete
917 </dt>
918 <dd>
920 Omit the preimage for deletes, i.e. print only the header but not
921 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
922 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
923 solely for people who want to just concentrate on reviewing the
924 text after the change. In addition, the output obviously lack
925 enough information to apply such a patch in reverse, even manually,
926 hence the name of the option.
927 </p>
928 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
929 of a delete/create pair.</p></div>
930 </dd>
931 <dt class="hdlist1">
932 -l&lt;num&gt;
933 </dt>
934 <dd>
936 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
937 is the number of potential rename/copy targets. This
938 option prevents rename/copy detection from running if
939 the number of rename/copy targets exceeds the specified
940 number.
941 </p>
942 </dd>
943 <dt class="hdlist1">
944 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
945 </dt>
946 <dd>
948 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
949 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
950 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
951 are Unmerged (<tt>U</tt>), are
952 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
953 Any combination of the filter characters (including none) can be used.
954 When <tt>*</tt> (All-or-none) is added to the combination, all
955 paths are selected if there is any file that matches
956 other criteria in the comparison; if there is no file
957 that matches other criteria, nothing is selected.
958 </p>
959 </dd>
960 <dt class="hdlist1">
961 -S&lt;string&gt;
962 </dt>
963 <dd>
965 Look for differences that introduce or remove an instance of
966 &lt;string&gt;. Note that this is different than the string simply
967 appearing in diff output; see the <em>pickaxe</em> entry in
968 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
969 </p>
970 </dd>
971 <dt class="hdlist1">
972 -G&lt;regex&gt;
973 </dt>
974 <dd>
976 Look for differences whose added or removed line matches
977 the given &lt;regex&gt;.
978 </p>
979 </dd>
980 <dt class="hdlist1">
981 --pickaxe-all
982 </dt>
983 <dd>
985 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
986 changeset, not just the files that contain the change
987 in &lt;string&gt;.
988 </p>
989 </dd>
990 <dt class="hdlist1">
991 --pickaxe-regex
992 </dt>
993 <dd>
995 Make the &lt;string&gt; not a plain string but an extended POSIX
996 regex to match.
997 </p>
998 </dd>
999 <dt class="hdlist1">
1000 -O&lt;orderfile&gt;
1001 </dt>
1002 <dd>
1004 Output the patch in the order specified in the
1005 &lt;orderfile&gt;, which has one shell glob pattern per line.
1006 </p>
1007 </dd>
1008 <dt class="hdlist1">
1010 </dt>
1011 <dd>
1013 Swap two inputs; that is, show differences from index or
1014 on-disk file to tree contents.
1015 </p>
1016 </dd>
1017 <dt class="hdlist1">
1018 --relative[=&lt;path&gt;]
1019 </dt>
1020 <dd>
1022 When run from a subdirectory of the project, it can be
1023 told to exclude changes outside the directory and show
1024 pathnames relative to it with this option. When you are
1025 not in a subdirectory (e.g. in a bare repository), you
1026 can name which subdirectory to make the output relative
1027 to by giving a &lt;path&gt; as an argument.
1028 </p>
1029 </dd>
1030 <dt class="hdlist1">
1032 </dt>
1033 <dt class="hdlist1">
1034 --text
1035 </dt>
1036 <dd>
1038 Treat all files as text.
1039 </p>
1040 </dd>
1041 <dt class="hdlist1">
1042 --ignore-space-at-eol
1043 </dt>
1044 <dd>
1046 Ignore changes in whitespace at EOL.
1047 </p>
1048 </dd>
1049 <dt class="hdlist1">
1051 </dt>
1052 <dt class="hdlist1">
1053 --ignore-space-change
1054 </dt>
1055 <dd>
1057 Ignore changes in amount of whitespace. This ignores whitespace
1058 at line end, and considers all other sequences of one or
1059 more whitespace characters to be equivalent.
1060 </p>
1061 </dd>
1062 <dt class="hdlist1">
1064 </dt>
1065 <dt class="hdlist1">
1066 --ignore-all-space
1067 </dt>
1068 <dd>
1070 Ignore whitespace when comparing lines. This ignores
1071 differences even if one line has whitespace where the other
1072 line has none.
1073 </p>
1074 </dd>
1075 <dt class="hdlist1">
1076 --inter-hunk-context=&lt;lines&gt;
1077 </dt>
1078 <dd>
1080 Show the context between diff hunks, up to the specified number
1081 of lines, thereby fusing hunks that are close to each other.
1082 </p>
1083 </dd>
1084 <dt class="hdlist1">
1085 --exit-code
1086 </dt>
1087 <dd>
1089 Make the program exit with codes similar to diff(1).
1090 That is, it exits with 1 if there were differences and
1091 0 means no differences.
1092 </p>
1093 </dd>
1094 <dt class="hdlist1">
1095 --quiet
1096 </dt>
1097 <dd>
1099 Disable all output of the program. Implies <tt>--exit-code</tt>.
1100 </p>
1101 </dd>
1102 <dt class="hdlist1">
1103 --ext-diff
1104 </dt>
1105 <dd>
1107 Allow an external diff helper to be executed. If you set an
1108 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1109 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1110 </p>
1111 </dd>
1112 <dt class="hdlist1">
1113 --no-ext-diff
1114 </dt>
1115 <dd>
1117 Disallow external diff drivers.
1118 </p>
1119 </dd>
1120 <dt class="hdlist1">
1121 --ignore-submodules[=&lt;when&gt;]
1122 </dt>
1123 <dd>
1125 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1126 either "none", "untracked", "dirty" or "all", which is the default
1127 Using "none" will consider the submodule modified when it either contains
1128 untracked or modified files or its HEAD differs from the commit recorded
1129 in the superproject and can be used to override any settings of the
1130 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1131 "untracked" is used submodules are not considered dirty when they only
1132 contain untracked content (but they are still scanned for modified
1133 content). Using "dirty" ignores all changes to the work tree of submodules,
1134 only changes to the commits stored in the superproject are shown (this was
1135 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1136 </p>
1137 </dd>
1138 <dt class="hdlist1">
1139 --src-prefix=&lt;prefix&gt;
1140 </dt>
1141 <dd>
1143 Show the given source prefix instead of "a/".
1144 </p>
1145 </dd>
1146 <dt class="hdlist1">
1147 --dst-prefix=&lt;prefix&gt;
1148 </dt>
1149 <dd>
1151 Show the given destination prefix instead of "b/".
1152 </p>
1153 </dd>
1154 <dt class="hdlist1">
1155 --no-prefix
1156 </dt>
1157 <dd>
1159 Do not show any source or destination prefix.
1160 </p>
1161 </dd>
1162 </dl></div>
1163 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1164 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1165 <div class="dlist"><dl>
1166 <dt class="hdlist1">
1167 &lt;path&gt;&#8230;
1168 </dt>
1169 <dd>
1171 The &lt;paths&gt; parameters, when given, are used to limit
1172 the diff to the named paths (you can give directory
1173 names and get diff for all files under them).
1174 </p>
1175 </dd>
1176 </dl></div>
1177 </div>
1178 <h2 id="_raw_output_format">Raw output format</h2>
1179 <div class="sectionbody">
1180 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1181 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1182 <div class="paragraph"><p>These commands all compare two sets of things; what is
1183 compared differs:</p></div>
1184 <div class="dlist"><dl>
1185 <dt class="hdlist1">
1186 git-diff-index &lt;tree-ish&gt;
1187 </dt>
1188 <dd>
1190 compares the &lt;tree-ish&gt; and the files on the filesystem.
1191 </p>
1192 </dd>
1193 <dt class="hdlist1">
1194 git-diff-index --cached &lt;tree-ish&gt;
1195 </dt>
1196 <dd>
1198 compares the &lt;tree-ish&gt; and the index.
1199 </p>
1200 </dd>
1201 <dt class="hdlist1">
1202 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1203 </dt>
1204 <dd>
1206 compares the trees named by the two arguments.
1207 </p>
1208 </dd>
1209 <dt class="hdlist1">
1210 git-diff-files [&lt;pattern&gt;&#8230;]
1211 </dt>
1212 <dd>
1214 compares the index and the files on the filesystem.
1215 </p>
1216 </dd>
1217 </dl></div>
1218 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1219 what is being compared. After that, all the commands print one output
1220 line per changed file.</p></div>
1221 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1222 <div class="listingblock">
1223 <div class="content">
1224 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1225 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1226 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1227 create :000000 100644 0000000... 1234567... A file4
1228 delete :100644 000000 1234567... 0000000... D file5
1229 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1230 </div></div>
1231 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1232 <div class="olist arabic"><ol class="arabic">
1233 <li>
1235 a colon.
1236 </p>
1237 </li>
1238 <li>
1240 mode for "src"; 000000 if creation or unmerged.
1241 </p>
1242 </li>
1243 <li>
1245 a space.
1246 </p>
1247 </li>
1248 <li>
1250 mode for "dst"; 000000 if deletion or unmerged.
1251 </p>
1252 </li>
1253 <li>
1255 a space.
1256 </p>
1257 </li>
1258 <li>
1260 sha1 for "src"; 0{40} if creation or unmerged.
1261 </p>
1262 </li>
1263 <li>
1265 a space.
1266 </p>
1267 </li>
1268 <li>
1270 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1271 </p>
1272 </li>
1273 <li>
1275 a space.
1276 </p>
1277 </li>
1278 <li>
1280 status, followed by optional "score" number.
1281 </p>
1282 </li>
1283 <li>
1285 a tab or a NUL when <em>-z</em> option is used.
1286 </p>
1287 </li>
1288 <li>
1290 path for "src"
1291 </p>
1292 </li>
1293 <li>
1295 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1296 </p>
1297 </li>
1298 <li>
1300 path for "dst"; only exists for C or R.
1301 </p>
1302 </li>
1303 <li>
1305 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1306 </p>
1307 </li>
1308 </ol></div>
1309 <div class="paragraph"><p>Possible status letters are:</p></div>
1310 <div class="ulist"><ul>
1311 <li>
1313 A: addition of a file
1314 </p>
1315 </li>
1316 <li>
1318 C: copy of a file into a new one
1319 </p>
1320 </li>
1321 <li>
1323 D: deletion of a file
1324 </p>
1325 </li>
1326 <li>
1328 M: modification of the contents or mode of a file
1329 </p>
1330 </li>
1331 <li>
1333 R: renaming of a file
1334 </p>
1335 </li>
1336 <li>
1338 T: change in the type of the file
1339 </p>
1340 </li>
1341 <li>
1343 U: file is unmerged (you must complete the merge before it can
1344 be committed)
1345 </p>
1346 </li>
1347 <li>
1349 X: "unknown" change type (most probably a bug, please report it)
1350 </p>
1351 </li>
1352 </ul></div>
1353 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1354 percentage of similarity between the source and target of the move or
1355 copy), and are the only ones to be so.</p></div>
1356 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1357 and it is out of sync with the index.</p></div>
1358 <div class="paragraph"><p>Example:</p></div>
1359 <div class="listingblock">
1360 <div class="content">
1361 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1362 </div></div>
1363 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1364 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1365 respectively.</p></div>
1366 </div>
1367 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1368 <div class="sectionbody">
1369 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1370 can take <em>-c</em> or <em>--cc</em> option
1371 to generate diff output also for merge commits. The output differs
1372 from the format described above in the following way:</p></div>
1373 <div class="olist arabic"><ol class="arabic">
1374 <li>
1376 there is a colon for each parent
1377 </p>
1378 </li>
1379 <li>
1381 there are more "src" modes and "src" sha1
1382 </p>
1383 </li>
1384 <li>
1386 status is concatenated status characters for each parent
1387 </p>
1388 </li>
1389 <li>
1391 no optional "score" number
1392 </p>
1393 </li>
1394 <li>
1396 single path, only for "dst"
1397 </p>
1398 </li>
1399 </ol></div>
1400 <div class="paragraph"><p>Example:</p></div>
1401 <div class="listingblock">
1402 <div class="content">
1403 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1404 </div></div>
1405 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1406 all parents.</p></div>
1407 </div>
1408 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1409 <div class="sectionbody">
1410 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1411 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1412 "git log" with the "-p" option, they
1413 do not produce the output described above; instead they produce a
1414 patch file. You can customize the creation of such patches via the
1415 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1416 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1417 diff format:</p></div>
1418 <div class="olist arabic"><ol class="arabic">
1419 <li>
1421 It is preceded with a "git diff" header that looks like this:
1422 </p>
1423 <div class="literalblock">
1424 <div class="content">
1425 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1426 </div></div>
1427 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1428 involved. Especially, even for a creation or a deletion,
1429 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1430 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1431 name of the source file of the rename/copy and the name of
1432 the file that rename/copy produces, respectively.</p></div>
1433 </li>
1434 <li>
1436 It is followed by one or more extended header lines:
1437 </p>
1438 <div class="literalblock">
1439 <div class="content">
1440 <pre><tt>old mode &lt;mode&gt;
1441 new mode &lt;mode&gt;
1442 deleted file mode &lt;mode&gt;
1443 new file mode &lt;mode&gt;
1444 copy from &lt;path&gt;
1445 copy to &lt;path&gt;
1446 rename from &lt;path&gt;
1447 rename to &lt;path&gt;
1448 similarity index &lt;number&gt;
1449 dissimilarity index &lt;number&gt;
1450 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1451 </div></div>
1452 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1453 and file permission bits.</p></div>
1454 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1455 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1456 the dissimilarity index is the percentage of changed lines. It
1457 is a rounded down integer, followed by a percent sign. The
1458 similarity index value of 100% is thus reserved for two equal
1459 files, while 100% dissimilarity means that no line from the old
1460 file made it into the new one.</p></div>
1461 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1462 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1463 separate lines indicate the old and the new mode.</p></div>
1464 </li>
1465 <li>
1467 TAB, LF, double quote and backslash characters in pathnames
1468 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1469 If there is need for such substitution then the whole
1470 pathname is put in double quotes.
1471 </p>
1472 </li>
1473 <li>
1475 All the <tt>file1</tt> files in the output refer to files before the
1476 commit, and all the <tt>file2</tt> files refer to files after the commit.
1477 It is incorrect to apply each change to each file sequentially. For
1478 example, this patch will swap a and b:
1479 </p>
1480 <div class="literalblock">
1481 <div class="content">
1482 <pre><tt>diff --git a/a b/b
1483 rename from a
1484 rename to b
1485 diff --git a/b b/a
1486 rename from b
1487 rename to a</tt></pre>
1488 </div></div>
1489 </li>
1490 </ol></div>
1491 </div>
1492 <h2 id="_combined_diff_format">combined diff format</h2>
1493 <div class="sectionbody">
1494 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1495 produce a <em>combined diff</em> when showing a merge. This is the default
1496 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1497 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1498 of these commands to force generation of diffs with individual parents
1499 of a merge.</p></div>
1500 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1501 <div class="listingblock">
1502 <div class="content">
1503 <pre><tt>diff --combined describe.c
1504 index fabadb8,cc95eb0..4866510
1505 --- a/describe.c
1506 +++ b/describe.c
1507 @@@ -98,20 -98,12 +98,20 @@@
1508 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1511 - static void describe(char *arg)
1512 -static void describe(struct commit *cmit, int last_one)
1513 ++static void describe(char *arg, int last_one)
1515 + unsigned char sha1[20];
1516 + struct commit *cmit;
1517 struct commit_list *list;
1518 static int initialized = 0;
1519 struct commit_name *n;
1521 + if (get_sha1(arg, sha1) &lt; 0)
1522 + usage(describe_usage);
1523 + cmit = lookup_commit_reference(sha1);
1524 + if (!cmit)
1525 + usage(describe_usage);
1527 if (!initialized) {
1528 initialized = 1;
1529 for_each_ref(get_name);</tt></pre>
1530 </div></div>
1531 <div class="olist arabic"><ol class="arabic">
1532 <li>
1534 It is preceded with a "git diff" header, that looks like
1535 this (when <em>-c</em> option is used):
1536 </p>
1537 <div class="literalblock">
1538 <div class="content">
1539 <pre><tt>diff --combined file</tt></pre>
1540 </div></div>
1541 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1542 <div class="literalblock">
1543 <div class="content">
1544 <pre><tt>diff --cc file</tt></pre>
1545 </div></div>
1546 </li>
1547 <li>
1549 It is followed by one or more extended header lines
1550 (this example shows a merge with two parents):
1551 </p>
1552 <div class="literalblock">
1553 <div class="content">
1554 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1555 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1556 new file mode &lt;mode&gt;
1557 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1558 </div></div>
1559 <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
1560 the &lt;mode&gt; is different from the rest. Extended headers with
1561 information about detected contents movement (renames and
1562 copying detection) are designed to work with diff of two
1563 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1564 </li>
1565 <li>
1567 It is followed by two-line from-file/to-file header
1568 </p>
1569 <div class="literalblock">
1570 <div class="content">
1571 <pre><tt>--- a/file
1572 +++ b/file</tt></pre>
1573 </div></div>
1574 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1575 format, <tt>/dev/null</tt> is used to signal created or deleted
1576 files.</p></div>
1577 </li>
1578 <li>
1580 Chunk header format is modified to prevent people from
1581 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1582 was created for review of merge commit changes, and was not
1583 meant for apply. The change is similar to the change in the
1584 extended <em>index</em> header:
1585 </p>
1586 <div class="literalblock">
1587 <div class="content">
1588 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1589 </div></div>
1590 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1591 header for combined diff format.</p></div>
1592 </li>
1593 </ol></div>
1594 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1595 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
1596 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1597 compares two or more files file1, file2,&#8230; with one file X, and
1598 shows how X differs from each of fileN. One column for each of
1599 fileN is prepended to the output line to note how X&#8217;s line is
1600 different from it.</p></div>
1601 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1602 fileN but it does not appear in the result. A <tt>+</tt> character
1603 in the column N means that the line appears in the result,
1604 and fileN does not have that line (in other words, the line was
1605 added, from the point of view of that parent).</p></div>
1606 <div class="paragraph"><p>In the above example output, the function signature was changed
1607 from both files (hence two <tt>-</tt> removals from both file1 and
1608 file2, plus <tt>++</tt> to mean one line that was added does not appear
1609 in either file1 nor file2). Also eight other lines are the same
1610 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1611 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1612 merge commit with the merge result (i.e. file1..fileN are the
1613 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1614 two unresolved merge parents with the working tree file
1615 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1616 "their version").</p></div>
1617 </div>
1618 <h2 id="_other_diff_formats">other diff formats</h2>
1619 <div class="sectionbody">
1620 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1621 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1622 output. These options can be combined with other options, such as
1623 <tt>-p</tt>, and are meant for human consumption.</p></div>
1624 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1625 formats the pathnames compactly by combining common prefix and suffix of
1626 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1627 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1628 <div class="listingblock">
1629 <div class="content">
1630 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1631 </div></div>
1632 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1633 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1634 like this:</p></div>
1635 <div class="listingblock">
1636 <div class="content">
1637 <pre><tt>1 2 README
1638 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1639 </div></div>
1640 <div class="paragraph"><p>That is, from left to right:</p></div>
1641 <div class="olist arabic"><ol class="arabic">
1642 <li>
1644 the number of added lines;
1645 </p>
1646 </li>
1647 <li>
1649 a tab;
1650 </p>
1651 </li>
1652 <li>
1654 the number of deleted lines;
1655 </p>
1656 </li>
1657 <li>
1659 a tab;
1660 </p>
1661 </li>
1662 <li>
1664 pathname (possibly with rename/copy information);
1665 </p>
1666 </li>
1667 <li>
1669 a newline.
1670 </p>
1671 </li>
1672 </ol></div>
1673 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1674 <div class="listingblock">
1675 <div class="content">
1676 <pre><tt>1 2 README NUL
1677 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1678 </div></div>
1679 <div class="paragraph"><p>That is:</p></div>
1680 <div class="olist arabic"><ol class="arabic">
1681 <li>
1683 the number of added lines;
1684 </p>
1685 </li>
1686 <li>
1688 a tab;
1689 </p>
1690 </li>
1691 <li>
1693 the number of deleted lines;
1694 </p>
1695 </li>
1696 <li>
1698 a tab;
1699 </p>
1700 </li>
1701 <li>
1703 a NUL (only exists if renamed/copied);
1704 </p>
1705 </li>
1706 <li>
1708 pathname in preimage;
1709 </p>
1710 </li>
1711 <li>
1713 a NUL (only exists if renamed/copied);
1714 </p>
1715 </li>
1716 <li>
1718 pathname in postimage (only exists if renamed/copied);
1719 </p>
1720 </li>
1721 <li>
1723 a NUL.
1724 </p>
1725 </li>
1726 </ol></div>
1727 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1728 scripts that read the output to tell if the current record being read is
1729 a single-path record or a rename/copy record without reading ahead.
1730 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1731 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1732 </div>
1733 <h2 id="_examples">EXAMPLES</h2>
1734 <div class="sectionbody">
1735 <div class="dlist"><dl>
1736 <dt class="hdlist1">
1737 Various ways to check your working tree
1738 </dt>
1739 <dd>
1740 <div class="listingblock">
1741 <div class="content">
1742 <pre><tt>$ git diff <b>&lt;1&gt;</b>
1743 $ git diff --cached <b>&lt;2&gt;</b>
1744 $ git diff HEAD <b>&lt;3&gt;</b></tt></pre>
1745 </div></div>
1746 <div class="colist arabic"><ol>
1747 <li>
1749 Changes in the working tree not yet staged for the next commit.
1750 </p>
1751 </li>
1752 <li>
1754 Changes between the index and your last commit; what you
1755 would be committing if you run "git commit" without "-a" option.
1756 </p>
1757 </li>
1758 <li>
1760 Changes in the working tree since your last commit; what you
1761 would be committing if you run "git commit -a"
1762 </p>
1763 </li>
1764 </ol></div>
1765 </dd>
1766 <dt class="hdlist1">
1767 Comparing with arbitrary commits
1768 </dt>
1769 <dd>
1770 <div class="listingblock">
1771 <div class="content">
1772 <pre><tt>$ git diff test <b>&lt;1&gt;</b>
1773 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
1774 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></tt></pre>
1775 </div></div>
1776 <div class="colist arabic"><ol>
1777 <li>
1779 Instead of using the tip of the current branch, compare with the
1780 tip of "test" branch.
1781 </p>
1782 </li>
1783 <li>
1785 Instead of comparing with the tip of "test" branch, compare with
1786 the tip of the current branch, but limit the comparison to the
1787 file "test".
1788 </p>
1789 </li>
1790 <li>
1792 Compare the version before the last commit and the last commit.
1793 </p>
1794 </li>
1795 </ol></div>
1796 </dd>
1797 <dt class="hdlist1">
1798 Comparing branches
1799 </dt>
1800 <dd>
1801 <div class="listingblock">
1802 <div class="content">
1803 <pre><tt>$ git diff topic master <b>&lt;1&gt;</b>
1804 $ git diff topic..master <b>&lt;2&gt;</b>
1805 $ git diff topic...master <b>&lt;3&gt;</b></tt></pre>
1806 </div></div>
1807 <div class="colist arabic"><ol>
1808 <li>
1810 Changes between the tips of the topic and the master branches.
1811 </p>
1812 </li>
1813 <li>
1815 Same as above.
1816 </p>
1817 </li>
1818 <li>
1820 Changes that occurred on the master branch since when the topic
1821 branch was started off it.
1822 </p>
1823 </li>
1824 </ol></div>
1825 </dd>
1826 <dt class="hdlist1">
1827 Limiting the diff output
1828 </dt>
1829 <dd>
1830 <div class="listingblock">
1831 <div class="content">
1832 <pre><tt>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
1833 $ git diff --name-status <b>&lt;2&gt;</b>
1834 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></tt></pre>
1835 </div></div>
1836 <div class="colist arabic"><ol>
1837 <li>
1839 Show only modification, rename and copy, but not addition
1840 nor deletion.
1841 </p>
1842 </li>
1843 <li>
1845 Show only names and the nature of change, but not actual
1846 diff output.
1847 </p>
1848 </li>
1849 <li>
1851 Limit diff output to named subtrees.
1852 </p>
1853 </li>
1854 </ol></div>
1855 </dd>
1856 <dt class="hdlist1">
1857 Munging the diff output
1858 </dt>
1859 <dd>
1860 <div class="listingblock">
1861 <div class="content">
1862 <pre><tt>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
1863 $ git diff -R <b>&lt;2&gt;</b></tt></pre>
1864 </div></div>
1865 <div class="colist arabic"><ol>
1866 <li>
1868 Spend extra cycles to find renames, copies and complete
1869 rewrites (very expensive).
1870 </p>
1871 </li>
1872 <li>
1874 Output diff in reverse.
1875 </p>
1876 </li>
1877 </ol></div>
1878 </dd>
1879 </dl></div>
1880 </div>
1881 <h2 id="_see_also">SEE ALSO</h2>
1882 <div class="sectionbody">
1883 <div class="paragraph"><p>diff(1),
1884 <a href="git-difftool.html">git-difftool(1)</a>,
1885 <a href="git-log.html">git-log(1)</a>,
1886 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
1887 <a href="git-format-patch.html">git-format-patch(1)</a>,
1888 <a href="git-apply.html">git-apply(1)</a></p></div>
1889 </div>
1890 <h2 id="_git">GIT</h2>
1891 <div class="sectionbody">
1892 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1893 </div>
1894 <div id="footer">
1895 <div id="footer-text">
1896 Last updated 2011-03-15 23:30:13 UTC
1897 </div>
1898 </div>
1899 </body>
1900 </html>