Autogenerated HTML docs for v1.7.5.1-217-g4e3aa
[git/jnareb-git.git] / git-diff.html
blob36e6b92306e07bc6bfcc5ed21dfb73da9698c683
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>git-diff(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-diff(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-diff -
411 Show changes between commits, commit and working tree, etc
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git diff</em> [options] [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
419 <em>git diff</em> [options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
420 <em>git diff</em> [options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
421 <em>git diff</em> [options] [--no-index] [--] &lt;path&gt; &lt;path&gt;</div>
422 <div class="verseblock-attribution">
423 </div></div>
424 </div>
425 <h2 id="_description">DESCRIPTION</h2>
426 <div class="sectionbody">
427 <div class="paragraph"><p>Show changes between the working tree and the index or a tree, changes
428 between the index and a tree, changes between two trees, or changes
429 between two files on disk.</p></div>
430 <div class="dlist"><dl>
431 <dt class="hdlist1">
432 <em>git diff</em> [--options] [--] [&lt;path&gt;&#8230;]
433 </dt>
434 <dd>
436 This form is to view the changes you made relative to
437 the index (staging area for the next commit). In other
438 words, the differences are what you <em>could</em> tell git to
439 further add to the index but you still haven&#8217;t. You can
440 stage these changes by using <a href="git-add.html">git-add(1)</a>.
441 </p>
442 <div class="paragraph"><p>If exactly two paths are given and at least one points outside
443 the current repository, <em>git diff</em> will compare the two files /
444 directories. This behavior can be forced by --no-index.</p></div>
445 </dd>
446 <dt class="hdlist1">
447 <em>git diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
448 </dt>
449 <dd>
451 This form is to view the changes you staged for the next
452 commit relative to the named &lt;commit&gt;. Typically you
453 would want comparison with the latest commit, so if you
454 do not give &lt;commit&gt;, it defaults to HEAD.
455 If HEAD does not exist (e.g. unborned branches) and
456 &lt;commit&gt; is not given, it shows all staged changes.
457 --staged is a synonym of --cached.
458 </p>
459 </dd>
460 <dt class="hdlist1">
461 <em>git diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
462 </dt>
463 <dd>
465 This form is to view the changes you have in your
466 working tree relative to the named &lt;commit&gt;. You can
467 use HEAD to compare it with the latest commit, or a
468 branch name to compare with the tip of a different
469 branch.
470 </p>
471 </dd>
472 <dt class="hdlist1">
473 <em>git diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
474 </dt>
475 <dd>
477 This is to view the changes between two arbitrary
478 &lt;commit&gt;.
479 </p>
480 </dd>
481 <dt class="hdlist1">
482 <em>git diff</em> [--options] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
483 </dt>
484 <dd>
486 This is synonymous to the previous form. If &lt;commit&gt; on
487 one side is omitted, it will have the same effect as
488 using HEAD instead.
489 </p>
490 </dd>
491 <dt class="hdlist1">
492 <em>git diff</em> [--options] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
493 </dt>
494 <dd>
496 This form is to view the changes on the branch containing
497 and up to the second &lt;commit&gt;, starting at a common ancestor
498 of both &lt;commit&gt;. "git diff A...B" is equivalent to
499 "git diff $(git-merge-base A B) B". You can omit any one
500 of &lt;commit&gt;, which has the same effect as using HEAD instead.
501 </p>
502 </dd>
503 </dl></div>
504 <div class="paragraph"><p>Just in case if you are doing something exotic, it should be
505 noted that all of the &lt;commit&gt; in the above description, except
506 in the last two forms that use ".." notations, can be any
507 &lt;tree&gt;. The third form (<em>git diff &lt;commit&gt; &lt;commit&gt;</em>) can also
508 be used to compare two &lt;blob&gt; objects.</p></div>
509 <div class="paragraph"><p>For a more complete list of ways to spell &lt;commit&gt;, see
510 "SPECIFYING REVISIONS" section in <a href="gitrevisions.html">gitrevisions(7)</a>.
511 However, "diff" is about comparing two <em>endpoints</em>, not ranges,
512 and the range notations ("&lt;commit&gt;..&lt;commit&gt;" and
513 "&lt;commit&gt;...&lt;commit&gt;") do not mean a range as defined in the
514 "SPECIFYING RANGES" section in <a href="gitrevisions.html">gitrevisions(7)</a>.</p></div>
515 </div>
516 <h2 id="_options">OPTIONS</h2>
517 <div class="sectionbody">
518 <div class="dlist"><dl>
519 <dt class="hdlist1">
521 </dt>
522 <dt class="hdlist1">
524 </dt>
525 <dt class="hdlist1">
526 --patch
527 </dt>
528 <dd>
530 Generate patch (see section on generating patches).
531 This is the default.
532 </p>
533 </dd>
534 <dt class="hdlist1">
535 -U&lt;n&gt;
536 </dt>
537 <dt class="hdlist1">
538 --unified=&lt;n&gt;
539 </dt>
540 <dd>
542 Generate diffs with &lt;n&gt; lines of context instead of
543 the usual three.
544 Implies <tt>-p</tt>.
545 </p>
546 </dd>
547 <dt class="hdlist1">
548 --raw
549 </dt>
550 <dd>
552 Generate the raw format.
554 </p>
555 </dd>
556 <dt class="hdlist1">
557 --patch-with-raw
558 </dt>
559 <dd>
561 Synonym for <tt>-p --raw</tt>.
562 </p>
563 </dd>
564 <dt class="hdlist1">
565 --patience
566 </dt>
567 <dd>
569 Generate a diff using the "patience diff" algorithm.
570 </p>
571 </dd>
572 <dt class="hdlist1">
573 --stat[=&lt;width&gt;[,&lt;name-width&gt;]]
574 </dt>
575 <dd>
577 Generate a diffstat. You can override the default
578 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
579 The width of the filename part can be controlled by
580 giving another width to it separated by a comma.
581 </p>
582 </dd>
583 <dt class="hdlist1">
584 --numstat
585 </dt>
586 <dd>
588 Similar to <tt>--stat</tt>, but shows number of added and
589 deleted lines in decimal notation and pathname without
590 abbreviation, to make it more machine friendly. For
591 binary files, outputs two <tt>-</tt> instead of saying
592 <tt>0 0</tt>.
593 </p>
594 </dd>
595 <dt class="hdlist1">
596 --shortstat
597 </dt>
598 <dd>
600 Output only the last line of the <tt>--stat</tt> format containing total
601 number of modified files, as well as number of added and deleted
602 lines.
603 </p>
604 </dd>
605 <dt class="hdlist1">
606 --dirstat[=&lt;limit&gt;]
607 </dt>
608 <dd>
610 Output the distribution of relative amount of changes (number of lines added or
611 removed) for each sub-directory. Directories with changes below
612 a cut-off percent (3% by default) are not shown. The cut-off percent
613 can be set with <tt>--dirstat=&lt;limit&gt;</tt>. Changes in a child directory are not
614 counted for the parent directory, unless <tt>--cumulative</tt> is used.
615 </p>
616 <div class="paragraph"><p>Note that the <tt>--dirstat</tt> option computes the changes while ignoring
617 the amount of pure code movements within a file. In other words,
618 rearranging lines in a file is not counted as much as other changes.</p></div>
619 </dd>
620 <dt class="hdlist1">
621 --dirstat-by-file[=&lt;limit&gt;]
622 </dt>
623 <dd>
625 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
626 </p>
627 </dd>
628 <dt class="hdlist1">
629 --summary
630 </dt>
631 <dd>
633 Output a condensed summary of extended header information
634 such as creations, renames and mode changes.
635 </p>
636 </dd>
637 <dt class="hdlist1">
638 --patch-with-stat
639 </dt>
640 <dd>
642 Synonym for <tt>-p --stat</tt>.
643 </p>
644 </dd>
645 <dt class="hdlist1">
647 </dt>
648 <dd>
650 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
651 given, do not munge pathnames and use NULs as output field terminators.
652 </p>
653 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
654 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
655 respectively, and the pathname will be enclosed in double quotes if
656 any of those replacements occurred.</p></div>
657 </dd>
658 <dt class="hdlist1">
659 --name-only
660 </dt>
661 <dd>
663 Show only names of changed files.
664 </p>
665 </dd>
666 <dt class="hdlist1">
667 --name-status
668 </dt>
669 <dd>
671 Show only names and status of changed files. See the description
672 of the <tt>--diff-filter</tt> option on what the status letters mean.
673 </p>
674 </dd>
675 <dt class="hdlist1">
676 --submodule[=&lt;format&gt;]
677 </dt>
678 <dd>
680 Chose the output format for submodule differences. &lt;format&gt; can be one of
681 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
682 is used when this option is not given. <em>log</em> is the default value for this
683 option and lists the commits in that commit range like the <em>summary</em>
684 option of <a href="git-submodule.html">git-submodule(1)</a> does.
685 </p>
686 </dd>
687 <dt class="hdlist1">
688 --color[=&lt;when&gt;]
689 </dt>
690 <dd>
692 Show colored diff.
693 The value must be <tt>always</tt> (the default for <tt>&lt;when&gt;</tt>), <tt>never</tt>, or <tt>auto</tt>.
694 The default value is <tt>never</tt>.
695 It can be changed by the <tt>color.ui</tt> and <tt>color.diff</tt>
696 configuration settings.
697 </p>
698 </dd>
699 <dt class="hdlist1">
700 --no-color
701 </dt>
702 <dd>
704 Turn off colored diff.
705 This can be used to override configuration settings.
706 It is the same as <tt>--color=never</tt>.
707 </p>
708 </dd>
709 <dt class="hdlist1">
710 --word-diff[=&lt;mode&gt;]
711 </dt>
712 <dd>
714 Show a word diff, using the &lt;mode&gt; to delimit changed words.
715 By default, words are delimited by whitespace; see
716 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
717 must be one of:
718 </p>
719 <div class="dlist"><dl>
720 <dt class="hdlist1">
721 color
722 </dt>
723 <dd>
725 Highlight changed words using only colors. Implies <tt>--color</tt>.
726 </p>
727 </dd>
728 <dt class="hdlist1">
729 plain
730 </dt>
731 <dd>
733 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
734 attempts to escape the delimiters if they appear in the input,
735 so the output may be ambiguous.
736 </p>
737 </dd>
738 <dt class="hdlist1">
739 porcelain
740 </dt>
741 <dd>
743 Use a special line-based format intended for script
744 consumption. Added/removed/unchanged runs are printed in the
745 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
746 character at the beginning of the line and extending to the
747 end of the line. Newlines in the input are represented by a
748 tilde <tt>~</tt> on a line of its own.
749 </p>
750 </dd>
751 <dt class="hdlist1">
752 none
753 </dt>
754 <dd>
756 Disable word diff again.
757 </p>
758 </dd>
759 </dl></div>
760 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
761 highlight the changed parts in all modes if enabled.</p></div>
762 </dd>
763 <dt class="hdlist1">
764 --word-diff-regex=&lt;regex&gt;
765 </dt>
766 <dd>
768 Use &lt;regex&gt; to decide what a word is, instead of considering
769 runs of non-whitespace to be a word. Also implies
770 <tt>--word-diff</tt> unless it was already enabled.
771 </p>
772 <div class="paragraph"><p>Every non-overlapping match of the
773 &lt;regex&gt; is considered a word. Anything between these matches is
774 considered whitespace and ignored(!) for the purposes of finding
775 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
776 expression to make sure that it matches all non-whitespace characters.
777 A match that contains a newline is silently truncated(!) at the
778 newline.</p></div>
779 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
780 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
781 overrides any diff driver or configuration setting. Diff drivers
782 override configuration settings.</p></div>
783 </dd>
784 <dt class="hdlist1">
785 --color-words[=&lt;regex&gt;]
786 </dt>
787 <dd>
789 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
790 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
791 </p>
792 </dd>
793 <dt class="hdlist1">
794 --no-renames
795 </dt>
796 <dd>
798 Turn off rename detection, even when the configuration
799 file gives the default to do so.
800 </p>
801 </dd>
802 <dt class="hdlist1">
803 --check
804 </dt>
805 <dd>
807 Warn if changes introduce trailing whitespace
808 or an indent that uses a space before a tab. Exits with
809 non-zero status if problems are found. Not compatible with
810 --exit-code.
811 </p>
812 </dd>
813 <dt class="hdlist1">
814 --full-index
815 </dt>
816 <dd>
818 Instead of the first handful of characters, show the full
819 pre- and post-image blob object names on the "index"
820 line when generating patch format output.
821 </p>
822 </dd>
823 <dt class="hdlist1">
824 --binary
825 </dt>
826 <dd>
828 In addition to <tt>--full-index</tt>, output a binary diff that
829 can be applied with <tt>git-apply</tt>.
830 </p>
831 </dd>
832 <dt class="hdlist1">
833 --abbrev[=&lt;n&gt;]
834 </dt>
835 <dd>
837 Instead of showing the full 40-byte hexadecimal object
838 name in diff-raw format output and diff-tree header
839 lines, show only a partial prefix. This is
840 independent of the <tt>--full-index</tt> option above, which controls
841 the diff-patch output format. Non default number of
842 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
843 </p>
844 </dd>
845 <dt class="hdlist1">
846 -B[&lt;n&gt;][/&lt;m&gt;]
847 </dt>
848 <dt class="hdlist1">
849 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
850 </dt>
851 <dd>
853 Break complete rewrite changes into pairs of delete and
854 create. This serves two purposes:
855 </p>
856 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
857 not as a series of deletion and insertion mixed together with a very
858 few lines that happen to match textually as the context, but as a
859 single deletion of everything old followed by a single insertion of
860 everything new, and the number <tt>m</tt> controls this aspect of the -B
861 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
862 original should remain in the result for git to consider it a total
863 rewrite (i.e. otherwise the resulting patch will be a series of
864 deletion and insertion mixed together with context lines).</p></div>
865 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
866 source of a rename (usually -M only considers a file that disappeared
867 as the source of a rename), and the number <tt>n</tt> controls this aspect of
868 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
869 addition and deletion compared to 20% or more of the file&#8217;s size are
870 eligible for being picked up as a possible source of a rename to
871 another file.</p></div>
872 </dd>
873 <dt class="hdlist1">
874 -M[&lt;n&gt;]
875 </dt>
876 <dt class="hdlist1">
877 --find-renames[=&lt;n&gt;]
878 </dt>
879 <dd>
881 Detect renames.
882 If <tt>n</tt> is specified, it is a threshold on the similarity
883 index (i.e. amount of addition/deletions compared to the
884 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
885 delete/add pair to be a rename if more than 90% of the file
886 hasn&#8217;t changed.
887 </p>
888 </dd>
889 <dt class="hdlist1">
890 -C[&lt;n&gt;]
891 </dt>
892 <dt class="hdlist1">
893 --find-copies[=&lt;n&gt;]
894 </dt>
895 <dd>
897 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
898 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
899 </p>
900 </dd>
901 <dt class="hdlist1">
902 --find-copies-harder
903 </dt>
904 <dd>
906 For performance reasons, by default, <tt>-C</tt> option finds copies only
907 if the original file of the copy was modified in the same
908 changeset. This flag makes the command
909 inspect unmodified files as candidates for the source of
910 copy. This is a very expensive operation for large
911 projects, so use it with caution. Giving more than one
912 <tt>-C</tt> option has the same effect.
913 </p>
914 </dd>
915 <dt class="hdlist1">
917 </dt>
918 <dt class="hdlist1">
919 --irreversible-delete
920 </dt>
921 <dd>
923 Omit the preimage for deletes, i.e. print only the header but not
924 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
925 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
926 solely for people who want to just concentrate on reviewing the
927 text after the change. In addition, the output obviously lack
928 enough information to apply such a patch in reverse, even manually,
929 hence the name of the option.
930 </p>
931 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
932 of a delete/create pair.</p></div>
933 </dd>
934 <dt class="hdlist1">
935 -l&lt;num&gt;
936 </dt>
937 <dd>
939 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
940 is the number of potential rename/copy targets. This
941 option prevents rename/copy detection from running if
942 the number of rename/copy targets exceeds the specified
943 number.
944 </p>
945 </dd>
946 <dt class="hdlist1">
947 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
948 </dt>
949 <dd>
951 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
952 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
953 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
954 are Unmerged (<tt>U</tt>), are
955 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
956 Any combination of the filter characters (including none) can be used.
957 When <tt>*</tt> (All-or-none) is added to the combination, all
958 paths are selected if there is any file that matches
959 other criteria in the comparison; if there is no file
960 that matches other criteria, nothing is selected.
961 </p>
962 </dd>
963 <dt class="hdlist1">
964 -S&lt;string&gt;
965 </dt>
966 <dd>
968 Look for differences that introduce or remove an instance of
969 &lt;string&gt;. Note that this is different than the string simply
970 appearing in diff output; see the <em>pickaxe</em> entry in
971 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
972 </p>
973 </dd>
974 <dt class="hdlist1">
975 -G&lt;regex&gt;
976 </dt>
977 <dd>
979 Look for differences whose added or removed line matches
980 the given &lt;regex&gt;.
981 </p>
982 </dd>
983 <dt class="hdlist1">
984 --pickaxe-all
985 </dt>
986 <dd>
988 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
989 changeset, not just the files that contain the change
990 in &lt;string&gt;.
991 </p>
992 </dd>
993 <dt class="hdlist1">
994 --pickaxe-regex
995 </dt>
996 <dd>
998 Make the &lt;string&gt; not a plain string but an extended POSIX
999 regex to match.
1000 </p>
1001 </dd>
1002 <dt class="hdlist1">
1003 -O&lt;orderfile&gt;
1004 </dt>
1005 <dd>
1007 Output the patch in the order specified in the
1008 &lt;orderfile&gt;, which has one shell glob pattern per line.
1009 </p>
1010 </dd>
1011 <dt class="hdlist1">
1013 </dt>
1014 <dd>
1016 Swap two inputs; that is, show differences from index or
1017 on-disk file to tree contents.
1018 </p>
1019 </dd>
1020 <dt class="hdlist1">
1021 --relative[=&lt;path&gt;]
1022 </dt>
1023 <dd>
1025 When run from a subdirectory of the project, it can be
1026 told to exclude changes outside the directory and show
1027 pathnames relative to it with this option. When you are
1028 not in a subdirectory (e.g. in a bare repository), you
1029 can name which subdirectory to make the output relative
1030 to by giving a &lt;path&gt; as an argument.
1031 </p>
1032 </dd>
1033 <dt class="hdlist1">
1035 </dt>
1036 <dt class="hdlist1">
1037 --text
1038 </dt>
1039 <dd>
1041 Treat all files as text.
1042 </p>
1043 </dd>
1044 <dt class="hdlist1">
1045 --ignore-space-at-eol
1046 </dt>
1047 <dd>
1049 Ignore changes in whitespace at EOL.
1050 </p>
1051 </dd>
1052 <dt class="hdlist1">
1054 </dt>
1055 <dt class="hdlist1">
1056 --ignore-space-change
1057 </dt>
1058 <dd>
1060 Ignore changes in amount of whitespace. This ignores whitespace
1061 at line end, and considers all other sequences of one or
1062 more whitespace characters to be equivalent.
1063 </p>
1064 </dd>
1065 <dt class="hdlist1">
1067 </dt>
1068 <dt class="hdlist1">
1069 --ignore-all-space
1070 </dt>
1071 <dd>
1073 Ignore whitespace when comparing lines. This ignores
1074 differences even if one line has whitespace where the other
1075 line has none.
1076 </p>
1077 </dd>
1078 <dt class="hdlist1">
1079 --inter-hunk-context=&lt;lines&gt;
1080 </dt>
1081 <dd>
1083 Show the context between diff hunks, up to the specified number
1084 of lines, thereby fusing hunks that are close to each other.
1085 </p>
1086 </dd>
1087 <dt class="hdlist1">
1088 --exit-code
1089 </dt>
1090 <dd>
1092 Make the program exit with codes similar to diff(1).
1093 That is, it exits with 1 if there were differences and
1094 0 means no differences.
1095 </p>
1096 </dd>
1097 <dt class="hdlist1">
1098 --quiet
1099 </dt>
1100 <dd>
1102 Disable all output of the program. Implies <tt>--exit-code</tt>.
1103 </p>
1104 </dd>
1105 <dt class="hdlist1">
1106 --ext-diff
1107 </dt>
1108 <dd>
1110 Allow an external diff helper to be executed. If you set an
1111 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1112 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1113 </p>
1114 </dd>
1115 <dt class="hdlist1">
1116 --no-ext-diff
1117 </dt>
1118 <dd>
1120 Disallow external diff drivers.
1121 </p>
1122 </dd>
1123 <dt class="hdlist1">
1124 --ignore-submodules[=&lt;when&gt;]
1125 </dt>
1126 <dd>
1128 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1129 either "none", "untracked", "dirty" or "all", which is the default
1130 Using "none" will consider the submodule modified when it either contains
1131 untracked or modified files or its HEAD differs from the commit recorded
1132 in the superproject and can be used to override any settings of the
1133 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1134 "untracked" is used submodules are not considered dirty when they only
1135 contain untracked content (but they are still scanned for modified
1136 content). Using "dirty" ignores all changes to the work tree of submodules,
1137 only changes to the commits stored in the superproject are shown (this was
1138 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1139 </p>
1140 </dd>
1141 <dt class="hdlist1">
1142 --src-prefix=&lt;prefix&gt;
1143 </dt>
1144 <dd>
1146 Show the given source prefix instead of "a/".
1147 </p>
1148 </dd>
1149 <dt class="hdlist1">
1150 --dst-prefix=&lt;prefix&gt;
1151 </dt>
1152 <dd>
1154 Show the given destination prefix instead of "b/".
1155 </p>
1156 </dd>
1157 <dt class="hdlist1">
1158 --no-prefix
1159 </dt>
1160 <dd>
1162 Do not show any source or destination prefix.
1163 </p>
1164 </dd>
1165 </dl></div>
1166 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1167 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1168 <div class="dlist"><dl>
1169 <dt class="hdlist1">
1170 &lt;path&gt;&#8230;
1171 </dt>
1172 <dd>
1174 The &lt;paths&gt; parameters, when given, are used to limit
1175 the diff to the named paths (you can give directory
1176 names and get diff for all files under them).
1177 </p>
1178 </dd>
1179 </dl></div>
1180 </div>
1181 <h2 id="_raw_output_format">Raw output format</h2>
1182 <div class="sectionbody">
1183 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1184 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1185 <div class="paragraph"><p>These commands all compare two sets of things; what is
1186 compared differs:</p></div>
1187 <div class="dlist"><dl>
1188 <dt class="hdlist1">
1189 git-diff-index &lt;tree-ish&gt;
1190 </dt>
1191 <dd>
1193 compares the &lt;tree-ish&gt; and the files on the filesystem.
1194 </p>
1195 </dd>
1196 <dt class="hdlist1">
1197 git-diff-index --cached &lt;tree-ish&gt;
1198 </dt>
1199 <dd>
1201 compares the &lt;tree-ish&gt; and the index.
1202 </p>
1203 </dd>
1204 <dt class="hdlist1">
1205 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1206 </dt>
1207 <dd>
1209 compares the trees named by the two arguments.
1210 </p>
1211 </dd>
1212 <dt class="hdlist1">
1213 git-diff-files [&lt;pattern&gt;&#8230;]
1214 </dt>
1215 <dd>
1217 compares the index and the files on the filesystem.
1218 </p>
1219 </dd>
1220 </dl></div>
1221 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1222 what is being compared. After that, all the commands print one output
1223 line per changed file.</p></div>
1224 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1225 <div class="listingblock">
1226 <div class="content">
1227 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1228 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1229 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1230 create :000000 100644 0000000... 1234567... A file4
1231 delete :100644 000000 1234567... 0000000... D file5
1232 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1233 </div></div>
1234 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1235 <div class="olist arabic"><ol class="arabic">
1236 <li>
1238 a colon.
1239 </p>
1240 </li>
1241 <li>
1243 mode for "src"; 000000 if creation or unmerged.
1244 </p>
1245 </li>
1246 <li>
1248 a space.
1249 </p>
1250 </li>
1251 <li>
1253 mode for "dst"; 000000 if deletion or unmerged.
1254 </p>
1255 </li>
1256 <li>
1258 a space.
1259 </p>
1260 </li>
1261 <li>
1263 sha1 for "src"; 0{40} if creation or unmerged.
1264 </p>
1265 </li>
1266 <li>
1268 a space.
1269 </p>
1270 </li>
1271 <li>
1273 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1274 </p>
1275 </li>
1276 <li>
1278 a space.
1279 </p>
1280 </li>
1281 <li>
1283 status, followed by optional "score" number.
1284 </p>
1285 </li>
1286 <li>
1288 a tab or a NUL when <em>-z</em> option is used.
1289 </p>
1290 </li>
1291 <li>
1293 path for "src"
1294 </p>
1295 </li>
1296 <li>
1298 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1299 </p>
1300 </li>
1301 <li>
1303 path for "dst"; only exists for C or R.
1304 </p>
1305 </li>
1306 <li>
1308 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1309 </p>
1310 </li>
1311 </ol></div>
1312 <div class="paragraph"><p>Possible status letters are:</p></div>
1313 <div class="ulist"><ul>
1314 <li>
1316 A: addition of a file
1317 </p>
1318 </li>
1319 <li>
1321 C: copy of a file into a new one
1322 </p>
1323 </li>
1324 <li>
1326 D: deletion of a file
1327 </p>
1328 </li>
1329 <li>
1331 M: modification of the contents or mode of a file
1332 </p>
1333 </li>
1334 <li>
1336 R: renaming of a file
1337 </p>
1338 </li>
1339 <li>
1341 T: change in the type of the file
1342 </p>
1343 </li>
1344 <li>
1346 U: file is unmerged (you must complete the merge before it can
1347 be committed)
1348 </p>
1349 </li>
1350 <li>
1352 X: "unknown" change type (most probably a bug, please report it)
1353 </p>
1354 </li>
1355 </ul></div>
1356 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1357 percentage of similarity between the source and target of the move or
1358 copy), and are the only ones to be so.</p></div>
1359 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1360 and it is out of sync with the index.</p></div>
1361 <div class="paragraph"><p>Example:</p></div>
1362 <div class="listingblock">
1363 <div class="content">
1364 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1365 </div></div>
1366 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1367 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1368 respectively.</p></div>
1369 </div>
1370 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1371 <div class="sectionbody">
1372 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1373 can take <em>-c</em> or <em>--cc</em> option
1374 to generate diff output also for merge commits. The output differs
1375 from the format described above in the following way:</p></div>
1376 <div class="olist arabic"><ol class="arabic">
1377 <li>
1379 there is a colon for each parent
1380 </p>
1381 </li>
1382 <li>
1384 there are more "src" modes and "src" sha1
1385 </p>
1386 </li>
1387 <li>
1389 status is concatenated status characters for each parent
1390 </p>
1391 </li>
1392 <li>
1394 no optional "score" number
1395 </p>
1396 </li>
1397 <li>
1399 single path, only for "dst"
1400 </p>
1401 </li>
1402 </ol></div>
1403 <div class="paragraph"><p>Example:</p></div>
1404 <div class="listingblock">
1405 <div class="content">
1406 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1407 </div></div>
1408 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1409 all parents.</p></div>
1410 </div>
1411 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1412 <div class="sectionbody">
1413 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1414 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1415 "git log" with the "-p" option, they
1416 do not produce the output described above; instead they produce a
1417 patch file. You can customize the creation of such patches via the
1418 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1419 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1420 diff format:</p></div>
1421 <div class="olist arabic"><ol class="arabic">
1422 <li>
1424 It is preceded with a "git diff" header that looks like this:
1425 </p>
1426 <div class="literalblock">
1427 <div class="content">
1428 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1429 </div></div>
1430 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1431 involved. Especially, even for a creation or a deletion,
1432 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1433 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1434 name of the source file of the rename/copy and the name of
1435 the file that rename/copy produces, respectively.</p></div>
1436 </li>
1437 <li>
1439 It is followed by one or more extended header lines:
1440 </p>
1441 <div class="literalblock">
1442 <div class="content">
1443 <pre><tt>old mode &lt;mode&gt;
1444 new mode &lt;mode&gt;
1445 deleted file mode &lt;mode&gt;
1446 new file mode &lt;mode&gt;
1447 copy from &lt;path&gt;
1448 copy to &lt;path&gt;
1449 rename from &lt;path&gt;
1450 rename to &lt;path&gt;
1451 similarity index &lt;number&gt;
1452 dissimilarity index &lt;number&gt;
1453 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1454 </div></div>
1455 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1456 and file permission bits.</p></div>
1457 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1458 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1459 the dissimilarity index is the percentage of changed lines. It
1460 is a rounded down integer, followed by a percent sign. The
1461 similarity index value of 100% is thus reserved for two equal
1462 files, while 100% dissimilarity means that no line from the old
1463 file made it into the new one.</p></div>
1464 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1465 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1466 separate lines indicate the old and the new mode.</p></div>
1467 </li>
1468 <li>
1470 TAB, LF, double quote and backslash characters in pathnames
1471 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1472 If there is need for such substitution then the whole
1473 pathname is put in double quotes.
1474 </p>
1475 </li>
1476 <li>
1478 All the <tt>file1</tt> files in the output refer to files before the
1479 commit, and all the <tt>file2</tt> files refer to files after the commit.
1480 It is incorrect to apply each change to each file sequentially. For
1481 example, this patch will swap a and b:
1482 </p>
1483 <div class="literalblock">
1484 <div class="content">
1485 <pre><tt>diff --git a/a b/b
1486 rename from a
1487 rename to b
1488 diff --git a/b b/a
1489 rename from b
1490 rename to a</tt></pre>
1491 </div></div>
1492 </li>
1493 </ol></div>
1494 </div>
1495 <h2 id="_combined_diff_format">combined diff format</h2>
1496 <div class="sectionbody">
1497 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1498 produce a <em>combined diff</em> when showing a merge. This is the default
1499 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1500 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1501 of these commands to force generation of diffs with individual parents
1502 of a merge.</p></div>
1503 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1504 <div class="listingblock">
1505 <div class="content">
1506 <pre><tt>diff --combined describe.c
1507 index fabadb8,cc95eb0..4866510
1508 --- a/describe.c
1509 +++ b/describe.c
1510 @@@ -98,20 -98,12 +98,20 @@@
1511 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1514 - static void describe(char *arg)
1515 -static void describe(struct commit *cmit, int last_one)
1516 ++static void describe(char *arg, int last_one)
1518 + unsigned char sha1[20];
1519 + struct commit *cmit;
1520 struct commit_list *list;
1521 static int initialized = 0;
1522 struct commit_name *n;
1524 + if (get_sha1(arg, sha1) &lt; 0)
1525 + usage(describe_usage);
1526 + cmit = lookup_commit_reference(sha1);
1527 + if (!cmit)
1528 + usage(describe_usage);
1530 if (!initialized) {
1531 initialized = 1;
1532 for_each_ref(get_name);</tt></pre>
1533 </div></div>
1534 <div class="olist arabic"><ol class="arabic">
1535 <li>
1537 It is preceded with a "git diff" header, that looks like
1538 this (when <em>-c</em> option is used):
1539 </p>
1540 <div class="literalblock">
1541 <div class="content">
1542 <pre><tt>diff --combined file</tt></pre>
1543 </div></div>
1544 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1545 <div class="literalblock">
1546 <div class="content">
1547 <pre><tt>diff --cc file</tt></pre>
1548 </div></div>
1549 </li>
1550 <li>
1552 It is followed by one or more extended header lines
1553 (this example shows a merge with two parents):
1554 </p>
1555 <div class="literalblock">
1556 <div class="content">
1557 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1558 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1559 new file mode &lt;mode&gt;
1560 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1561 </div></div>
1562 <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
1563 the &lt;mode&gt; is different from the rest. Extended headers with
1564 information about detected contents movement (renames and
1565 copying detection) are designed to work with diff of two
1566 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1567 </li>
1568 <li>
1570 It is followed by two-line from-file/to-file header
1571 </p>
1572 <div class="literalblock">
1573 <div class="content">
1574 <pre><tt>--- a/file
1575 +++ b/file</tt></pre>
1576 </div></div>
1577 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1578 format, <tt>/dev/null</tt> is used to signal created or deleted
1579 files.</p></div>
1580 </li>
1581 <li>
1583 Chunk header format is modified to prevent people from
1584 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1585 was created for review of merge commit changes, and was not
1586 meant for apply. The change is similar to the change in the
1587 extended <em>index</em> header:
1588 </p>
1589 <div class="literalblock">
1590 <div class="content">
1591 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1592 </div></div>
1593 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1594 header for combined diff format.</p></div>
1595 </li>
1596 </ol></div>
1597 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1598 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
1599 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1600 compares two or more files file1, file2,&#8230; with one file X, and
1601 shows how X differs from each of fileN. One column for each of
1602 fileN is prepended to the output line to note how X&#8217;s line is
1603 different from it.</p></div>
1604 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1605 fileN but it does not appear in the result. A <tt>+</tt> character
1606 in the column N means that the line appears in the result,
1607 and fileN does not have that line (in other words, the line was
1608 added, from the point of view of that parent).</p></div>
1609 <div class="paragraph"><p>In the above example output, the function signature was changed
1610 from both files (hence two <tt>-</tt> removals from both file1 and
1611 file2, plus <tt>++</tt> to mean one line that was added does not appear
1612 in either file1 nor file2). Also eight other lines are the same
1613 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1614 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1615 merge commit with the merge result (i.e. file1..fileN are the
1616 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1617 two unresolved merge parents with the working tree file
1618 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1619 "their version").</p></div>
1620 </div>
1621 <h2 id="_other_diff_formats">other diff formats</h2>
1622 <div class="sectionbody">
1623 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1624 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1625 output. These options can be combined with other options, such as
1626 <tt>-p</tt>, and are meant for human consumption.</p></div>
1627 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1628 formats the pathnames compactly by combining common prefix and suffix of
1629 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1630 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1631 <div class="listingblock">
1632 <div class="content">
1633 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1634 </div></div>
1635 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1636 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1637 like this:</p></div>
1638 <div class="listingblock">
1639 <div class="content">
1640 <pre><tt>1 2 README
1641 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1642 </div></div>
1643 <div class="paragraph"><p>That is, from left to right:</p></div>
1644 <div class="olist arabic"><ol class="arabic">
1645 <li>
1647 the number of added lines;
1648 </p>
1649 </li>
1650 <li>
1652 a tab;
1653 </p>
1654 </li>
1655 <li>
1657 the number of deleted lines;
1658 </p>
1659 </li>
1660 <li>
1662 a tab;
1663 </p>
1664 </li>
1665 <li>
1667 pathname (possibly with rename/copy information);
1668 </p>
1669 </li>
1670 <li>
1672 a newline.
1673 </p>
1674 </li>
1675 </ol></div>
1676 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1677 <div class="listingblock">
1678 <div class="content">
1679 <pre><tt>1 2 README NUL
1680 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1681 </div></div>
1682 <div class="paragraph"><p>That is:</p></div>
1683 <div class="olist arabic"><ol class="arabic">
1684 <li>
1686 the number of added lines;
1687 </p>
1688 </li>
1689 <li>
1691 a tab;
1692 </p>
1693 </li>
1694 <li>
1696 the number of deleted lines;
1697 </p>
1698 </li>
1699 <li>
1701 a tab;
1702 </p>
1703 </li>
1704 <li>
1706 a NUL (only exists if renamed/copied);
1707 </p>
1708 </li>
1709 <li>
1711 pathname in preimage;
1712 </p>
1713 </li>
1714 <li>
1716 a NUL (only exists if renamed/copied);
1717 </p>
1718 </li>
1719 <li>
1721 pathname in postimage (only exists if renamed/copied);
1722 </p>
1723 </li>
1724 <li>
1726 a NUL.
1727 </p>
1728 </li>
1729 </ol></div>
1730 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1731 scripts that read the output to tell if the current record being read is
1732 a single-path record or a rename/copy record without reading ahead.
1733 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1734 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1735 </div>
1736 <h2 id="_examples">EXAMPLES</h2>
1737 <div class="sectionbody">
1738 <div class="dlist"><dl>
1739 <dt class="hdlist1">
1740 Various ways to check your working tree
1741 </dt>
1742 <dd>
1743 <div class="listingblock">
1744 <div class="content">
1745 <pre><tt>$ git diff <b>&lt;1&gt;</b>
1746 $ git diff --cached <b>&lt;2&gt;</b>
1747 $ git diff HEAD <b>&lt;3&gt;</b></tt></pre>
1748 </div></div>
1749 <div class="colist arabic"><ol>
1750 <li>
1752 Changes in the working tree not yet staged for the next commit.
1753 </p>
1754 </li>
1755 <li>
1757 Changes between the index and your last commit; what you
1758 would be committing if you run "git commit" without "-a" option.
1759 </p>
1760 </li>
1761 <li>
1763 Changes in the working tree since your last commit; what you
1764 would be committing if you run "git commit -a"
1765 </p>
1766 </li>
1767 </ol></div>
1768 </dd>
1769 <dt class="hdlist1">
1770 Comparing with arbitrary commits
1771 </dt>
1772 <dd>
1773 <div class="listingblock">
1774 <div class="content">
1775 <pre><tt>$ git diff test <b>&lt;1&gt;</b>
1776 $ git diff HEAD -- ./test <b>&lt;2&gt;</b>
1777 $ git diff HEAD^ HEAD <b>&lt;3&gt;</b></tt></pre>
1778 </div></div>
1779 <div class="colist arabic"><ol>
1780 <li>
1782 Instead of using the tip of the current branch, compare with the
1783 tip of "test" branch.
1784 </p>
1785 </li>
1786 <li>
1788 Instead of comparing with the tip of "test" branch, compare with
1789 the tip of the current branch, but limit the comparison to the
1790 file "test".
1791 </p>
1792 </li>
1793 <li>
1795 Compare the version before the last commit and the last commit.
1796 </p>
1797 </li>
1798 </ol></div>
1799 </dd>
1800 <dt class="hdlist1">
1801 Comparing branches
1802 </dt>
1803 <dd>
1804 <div class="listingblock">
1805 <div class="content">
1806 <pre><tt>$ git diff topic master <b>&lt;1&gt;</b>
1807 $ git diff topic..master <b>&lt;2&gt;</b>
1808 $ git diff topic...master <b>&lt;3&gt;</b></tt></pre>
1809 </div></div>
1810 <div class="colist arabic"><ol>
1811 <li>
1813 Changes between the tips of the topic and the master branches.
1814 </p>
1815 </li>
1816 <li>
1818 Same as above.
1819 </p>
1820 </li>
1821 <li>
1823 Changes that occurred on the master branch since when the topic
1824 branch was started off it.
1825 </p>
1826 </li>
1827 </ol></div>
1828 </dd>
1829 <dt class="hdlist1">
1830 Limiting the diff output
1831 </dt>
1832 <dd>
1833 <div class="listingblock">
1834 <div class="content">
1835 <pre><tt>$ git diff --diff-filter=MRC <b>&lt;1&gt;</b>
1836 $ git diff --name-status <b>&lt;2&gt;</b>
1837 $ git diff arch/i386 include/asm-i386 <b>&lt;3&gt;</b></tt></pre>
1838 </div></div>
1839 <div class="colist arabic"><ol>
1840 <li>
1842 Show only modification, rename and copy, but not addition
1843 nor deletion.
1844 </p>
1845 </li>
1846 <li>
1848 Show only names and the nature of change, but not actual
1849 diff output.
1850 </p>
1851 </li>
1852 <li>
1854 Limit diff output to named subtrees.
1855 </p>
1856 </li>
1857 </ol></div>
1858 </dd>
1859 <dt class="hdlist1">
1860 Munging the diff output
1861 </dt>
1862 <dd>
1863 <div class="listingblock">
1864 <div class="content">
1865 <pre><tt>$ git diff --find-copies-harder -B -C <b>&lt;1&gt;</b>
1866 $ git diff -R <b>&lt;2&gt;</b></tt></pre>
1867 </div></div>
1868 <div class="colist arabic"><ol>
1869 <li>
1871 Spend extra cycles to find renames, copies and complete
1872 rewrites (very expensive).
1873 </p>
1874 </li>
1875 <li>
1877 Output diff in reverse.
1878 </p>
1879 </li>
1880 </ol></div>
1881 </dd>
1882 </dl></div>
1883 </div>
1884 <h2 id="_see_also">SEE ALSO</h2>
1885 <div class="sectionbody">
1886 <div class="paragraph"><p>diff(1),
1887 <a href="git-difftool.html">git-difftool(1)</a>,
1888 <a href="git-log.html">git-log(1)</a>,
1889 <a href="gitdiffcore.html">gitdiffcore(7)</a>,
1890 <a href="git-format-patch.html">git-format-patch(1)</a>,
1891 <a href="git-apply.html">git-apply(1)</a></p></div>
1892 </div>
1893 <h2 id="_git">GIT</h2>
1894 <div class="sectionbody">
1895 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1896 </div>
1897 <div id="footer">
1898 <div id="footer-text">
1899 Last updated 2011-03-15 23:30:13 UTC
1900 </div>
1901 </div>
1902 </body>
1903 </html>