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