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