Autogenerated HTML docs for v1.7.4.2-414-g07514
[git/jnareb-git.git] / git-diff.html
blob5bb7312418b03ba241bdb9aa794de6689a728800
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>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1473 produce a <em>combined diff</em> when showing a merge. This is the default
1474 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1475 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1476 of these commands to force generation of diffs with individual parents
1477 of a merge.</p></div>
1478 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1479 <div class="listingblock">
1480 <div class="content">
1481 <pre><tt>diff --combined describe.c
1482 index fabadb8,cc95eb0..4866510
1483 --- a/describe.c
1484 +++ b/describe.c
1485 @@@ -98,20 -98,12 +98,20 @@@
1486 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1489 - static void describe(char *arg)
1490 -static void describe(struct commit *cmit, int last_one)
1491 ++static void describe(char *arg, int last_one)
1493 + unsigned char sha1[20];
1494 + struct commit *cmit;
1495 struct commit_list *list;
1496 static int initialized = 0;
1497 struct commit_name *n;
1499 + if (get_sha1(arg, sha1) &lt; 0)
1500 + usage(describe_usage);
1501 + cmit = lookup_commit_reference(sha1);
1502 + if (!cmit)
1503 + usage(describe_usage);
1505 if (!initialized) {
1506 initialized = 1;
1507 for_each_ref(get_name);</tt></pre>
1508 </div></div>
1509 <div class="olist arabic"><ol class="arabic">
1510 <li>
1512 It is preceded with a "git diff" header, that looks like
1513 this (when <em>-c</em> option is used):
1514 </p>
1515 <div class="literalblock">
1516 <div class="content">
1517 <pre><tt>diff --combined file</tt></pre>
1518 </div></div>
1519 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1520 <div class="literalblock">
1521 <div class="content">
1522 <pre><tt>diff --cc file</tt></pre>
1523 </div></div>
1524 </li>
1525 <li>
1527 It is followed by one or more extended header lines
1528 (this example shows a merge with two parents):
1529 </p>
1530 <div class="literalblock">
1531 <div class="content">
1532 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1533 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1534 new file mode &lt;mode&gt;
1535 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1536 </div></div>
1537 <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
1538 the &lt;mode&gt; is different from the rest. Extended headers with
1539 information about detected contents movement (renames and
1540 copying detection) are designed to work with diff of two
1541 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1542 </li>
1543 <li>
1545 It is followed by two-line from-file/to-file header
1546 </p>
1547 <div class="literalblock">
1548 <div class="content">
1549 <pre><tt>--- a/file
1550 +++ b/file</tt></pre>
1551 </div></div>
1552 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1553 format, <tt>/dev/null</tt> is used to signal created or deleted
1554 files.</p></div>
1555 </li>
1556 <li>
1558 Chunk header format is modified to prevent people from
1559 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1560 was created for review of merge commit changes, and was not
1561 meant for apply. The change is similar to the change in the
1562 extended <em>index</em> header:
1563 </p>
1564 <div class="literalblock">
1565 <div class="content">
1566 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1567 </div></div>
1568 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1569 header for combined diff format.</p></div>
1570 </li>
1571 </ol></div>
1572 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1573 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
1574 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1575 compares two or more files file1, file2,&#8230; with one file X, and
1576 shows how X differs from each of fileN. One column for each of
1577 fileN is prepended to the output line to note how X&#8217;s line is
1578 different from it.</p></div>
1579 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1580 fileN but it does not appear in the result. A <tt>+</tt> character
1581 in the column N means that the line appears in the result,
1582 and fileN does not have that line (in other words, the line was
1583 added, from the point of view of that parent).</p></div>
1584 <div class="paragraph"><p>In the above example output, the function signature was changed
1585 from both files (hence two <tt>-</tt> removals from both file1 and
1586 file2, plus <tt>++</tt> to mean one line that was added does not appear
1587 in either file1 nor file2). Also eight other lines are the same
1588 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1589 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1590 merge commit with the merge result (i.e. file1..fileN are the
1591 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1592 two unresolved merge parents with the working tree file
1593 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1594 "their version").</p></div>
1595 </div>
1596 <h2 id="_other_diff_formats">other diff formats</h2>
1597 <div class="sectionbody">
1598 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1599 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1600 output. These options can be combined with other options, such as
1601 <tt>-p</tt>, and are meant for human consumption.</p></div>
1602 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1603 formats the pathnames compactly by combining common prefix and suffix of
1604 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1605 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1606 <div class="listingblock">
1607 <div class="content">
1608 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1609 </div></div>
1610 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1611 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1612 like this:</p></div>
1613 <div class="listingblock">
1614 <div class="content">
1615 <pre><tt>1 2 README
1616 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1617 </div></div>
1618 <div class="paragraph"><p>That is, from left to right:</p></div>
1619 <div class="olist arabic"><ol class="arabic">
1620 <li>
1622 the number of added lines;
1623 </p>
1624 </li>
1625 <li>
1627 a tab;
1628 </p>
1629 </li>
1630 <li>
1632 the number of deleted lines;
1633 </p>
1634 </li>
1635 <li>
1637 a tab;
1638 </p>
1639 </li>
1640 <li>
1642 pathname (possibly with rename/copy information);
1643 </p>
1644 </li>
1645 <li>
1647 a newline.
1648 </p>
1649 </li>
1650 </ol></div>
1651 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1652 <div class="listingblock">
1653 <div class="content">
1654 <pre><tt>1 2 README NUL
1655 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1656 </div></div>
1657 <div class="paragraph"><p>That is:</p></div>
1658 <div class="olist arabic"><ol class="arabic">
1659 <li>
1661 the number of added lines;
1662 </p>
1663 </li>
1664 <li>
1666 a tab;
1667 </p>
1668 </li>
1669 <li>
1671 the number of deleted lines;
1672 </p>
1673 </li>
1674 <li>
1676 a tab;
1677 </p>
1678 </li>
1679 <li>
1681 a NUL (only exists if renamed/copied);
1682 </p>
1683 </li>
1684 <li>
1686 pathname in preimage;
1687 </p>
1688 </li>
1689 <li>
1691 a NUL (only exists if renamed/copied);
1692 </p>
1693 </li>
1694 <li>
1696 pathname in postimage (only exists if renamed/copied);
1697 </p>
1698 </li>
1699 <li>
1701 a NUL.
1702 </p>
1703 </li>
1704 </ol></div>
1705 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1706 scripts that read the output to tell if the current record being read is
1707 a single-path record or a rename/copy record without reading ahead.
1708 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1709 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1710 </div>
1711 <h2 id="_examples">EXAMPLES</h2>
1712 <div class="sectionbody">
1713 <div class="dlist"><dl>
1714 <dt class="hdlist1">
1715 Various ways to check your working tree
1716 </dt>
1717 <dd>
1718 <div class="listingblock">
1719 <div class="content">
1720 <pre><tt>$ git diff <b>&lt;1&gt;</b>
1721 $ git diff --cached <b>&lt;2&gt;</b>
1722 $ git diff HEAD <b>&lt;3&gt;</b></tt></pre>
1723 </div></div>
1724 <div class="colist arabic"><ol>
1725 <li>
1727 Changes in the working tree not yet staged for the next commit.
1728 </p>
1729 </li>
1730 <li>
1732 Changes between the index and your last commit; what you
1733 would be committing if you run "git commit" without "-a" option.
1734 </p>
1735 </li>
1736 <li>
1738 Changes in the working tree since your last commit; what you
1739 would be committing if you run "git commit -a"
1740 </p>
1741 </li>
1742 </ol></div>
1743 </dd>
1744 <dt class="hdlist1">
1745 Comparing with arbitrary commits
1746 </dt>
1747 <dd>
1748 <div class="listingblock">
1749 <div class="content">
1750 <pre><tt>$ git diff test <b>&lt;1&gt;</b>
1751 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
1752 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></tt></pre>
1753 </div></div>
1754 <div class="colist arabic"><ol>
1755 <li>
1757 Instead of using the tip of the current branch, compare with the
1758 tip of "test" branch.
1759 </p>
1760 </li>
1761 <li>
1763 Instead of comparing with the tip of "test" branch, compare with
1764 the tip of the current branch, but limit the comparison to the
1765 file "test".
1766 </p>
1767 </li>
1768 <li>
1770 Compare the version before the last commit and the last commit.
1771 </p>
1772 </li>
1773 </ol></div>
1774 </dd>
1775 <dt class="hdlist1">
1776 Comparing branches
1777 </dt>
1778 <dd>
1779 <div class="listingblock">
1780 <div class="content">
1781 <pre><tt>$ git diff topic master <b>&lt;1&gt;</b>
1782 $ git diff topic..master <b>&lt;2&gt;</b>
1783 $ git diff topic...master <b>&lt;3&gt;</b></tt></pre>
1784 </div></div>
1785 <div class="colist arabic"><ol>
1786 <li>
1788 Changes between the tips of the topic and the master branches.
1789 </p>
1790 </li>
1791 <li>
1793 Same as above.
1794 </p>
1795 </li>
1796 <li>
1798 Changes that occurred on the master branch since when the topic
1799 branch was started off it.
1800 </p>
1801 </li>
1802 </ol></div>
1803 </dd>
1804 <dt class="hdlist1">
1805 Limiting the diff output
1806 </dt>
1807 <dd>
1808 <div class="listingblock">
1809 <div class="content">
1810 <pre><tt>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
1811 $ git diff --name-status <b>&lt;2&gt;</b>
1812 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></tt></pre>
1813 </div></div>
1814 <div class="colist arabic"><ol>
1815 <li>
1817 Show only modification, rename and copy, but not addition
1818 nor deletion.
1819 </p>
1820 </li>
1821 <li>
1823 Show only names and the nature of change, but not actual
1824 diff output.
1825 </p>
1826 </li>
1827 <li>
1829 Limit diff output to named subtrees.
1830 </p>
1831 </li>
1832 </ol></div>
1833 </dd>
1834 <dt class="hdlist1">
1835 Munging the diff output
1836 </dt>
1837 <dd>
1838 <div class="listingblock">
1839 <div class="content">
1840 <pre><tt>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
1841 $ git diff -R <b>&lt;2&gt;</b></tt></pre>
1842 </div></div>
1843 <div class="colist arabic"><ol>
1844 <li>
1846 Spend extra cycles to find renames, copies and complete
1847 rewrites (very expensive).
1848 </p>
1849 </li>
1850 <li>
1852 Output diff in reverse.
1853 </p>
1854 </li>
1855 </ol></div>
1856 </dd>
1857 </dl></div>
1858 </div>
1859 <h2 id="_see_also">SEE ALSO</h2>
1860 <div class="sectionbody">
1861 <div class="paragraph"><p>diff(1),
1862 <a href="git-difftool.html">git-difftool(1)</a>,
1863 <a href="git-log.html">git-log(1)</a>,
1864 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
1865 <a href="git-format-patch.html">git-format-patch(1)</a>,
1866 <a href="git-apply.html">git-apply(1)</a></p></div>
1867 </div>
1868 <h2 id="_git">GIT</h2>
1869 <div class="sectionbody">
1870 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1871 </div>
1872 <div id="footer">
1873 <div id="footer-text">
1874 Last updated 2011-03-15 23:30:13 UTC
1875 </div>
1876 </div>
1877 </body>
1878 </html>