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