Autogenerated HTML docs for v1.6.3.1-244-gf9275
[git/jnareb-git.git] / git-diff.html
blob21d846700fb05cf77a59a294561294f34fb11ddc
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.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-diff(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-diff(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-diff -
317 Show changes between commits, commit and working tree, etc
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="para"><p><em>git diff</em> [&lt;common diff options&gt;] &lt;commit&gt;{0,2} [--] [&lt;path&gt;&#8230;]</p></div>
324 </div>
325 <h2 id="_description">DESCRIPTION</h2>
326 <div class="sectionbody">
327 <div class="para"><p>Show changes between two trees, a tree and the working tree, a
328 tree and the index file, or the index file and the working tree.</p></div>
329 <div class="vlist"><dl>
330 <dt>
331 <em>git diff</em> [--options] [--] [&lt;path&gt;&#8230;]
332 </dt>
333 <dd>
335 This form is to view the changes you made relative to
336 the index (staging area for the next commit). In other
337 words, the differences are what you _could_ tell git to
338 further add to the index but you still haven't. You can
339 stage these changes by using <a href="git-add.html">git-add(1)</a>.
340 </p>
341 <div class="para"><p>If exactly two paths are given, and at least one is untracked,
342 compare the two files / directories. This behavior can be
343 forced by --no-index.</p></div>
344 </dd>
345 <dt>
346 <em>git diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
347 </dt>
348 <dd>
350 This form is to view the changes you staged for the next
351 commit relative to the named &lt;commit&gt;. Typically you
352 would want comparison with the latest commit, so if you
353 do not give &lt;commit&gt;, it defaults to HEAD.
354 --staged is a synonym of --cached.
355 </p>
356 </dd>
357 <dt>
358 <em>git diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
359 </dt>
360 <dd>
362 This form is to view the changes you have in your
363 working tree relative to the named &lt;commit&gt;. You can
364 use HEAD to compare it with the latest commit, or a
365 branch name to compare with the tip of a different
366 branch.
367 </p>
368 </dd>
369 <dt>
370 <em>git diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
371 </dt>
372 <dd>
374 This is to view the changes between two arbitrary
375 &lt;commit&gt;.
376 </p>
377 </dd>
378 <dt>
379 <em>git diff</em> [--options] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
380 </dt>
381 <dd>
383 This is synonymous to the previous form. If &lt;commit&gt; on
384 one side is omitted, it will have the same effect as
385 using HEAD instead.
386 </p>
387 </dd>
388 <dt>
389 <em>git diff</em> [--options] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
390 </dt>
391 <dd>
393 This form is to view the changes on the branch containing
394 and up to the second &lt;commit&gt;, starting at a common ancestor
395 of both &lt;commit&gt;. "git diff A...B" is equivalent to
396 "git diff $(git-merge-base A B) B". You can omit any one
397 of &lt;commit&gt;, which has the same effect as using HEAD instead.
398 </p>
399 </dd>
400 </dl></div>
401 <div class="para"><p>Just in case if you are doing something exotic, it should be
402 noted that all of the &lt;commit&gt; in the above description, except
403 for the last two forms that use ".." notations, can be any
404 &lt;tree-ish&gt;.</p></div>
405 <div class="para"><p>For a more complete list of ways to spell &lt;commit&gt;, see
406 "SPECIFYING REVISIONS" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.
407 However, "diff" is about comparing two _endpoints_, not ranges,
408 and the range notations ("&lt;commit&gt;..&lt;commit&gt;" and
409 "&lt;commit&gt;...&lt;commit&gt;") do not mean a range as defined in the
410 "SPECIFYING RANGES" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.</p></div>
411 </div>
412 <h2 id="_options">OPTIONS</h2>
413 <div class="sectionbody">
414 <div class="vlist"><dl>
415 <dt>
417 </dt>
418 <dt>
420 </dt>
421 <dd>
423 Generate patch (see section on generating patches).
424 This is the default.
425 </p>
426 </dd>
427 <dt>
428 -U&lt;n&gt;
429 </dt>
430 <dt>
431 --unified=&lt;n&gt;
432 </dt>
433 <dd>
435 Generate diffs with &lt;n&gt; lines of context instead of
436 the usual three. Implies "-p".
437 </p>
438 </dd>
439 <dt>
440 --raw
441 </dt>
442 <dd>
444 Generate the raw format.
446 </p>
447 </dd>
448 <dt>
449 --patch-with-raw
450 </dt>
451 <dd>
453 Synonym for "-p --raw".
454 </p>
455 </dd>
456 <dt>
457 --patience
458 </dt>
459 <dd>
461 Generate a diff using the "patience diff" algorithm.
462 </p>
463 </dd>
464 <dt>
465 --stat[=width[,name-width]]
466 </dt>
467 <dd>
469 Generate a diffstat. You can override the default
470 output width for 80-column terminal by "--stat=width".
471 The width of the filename part can be controlled by
472 giving another width to it separated by a comma.
473 </p>
474 </dd>
475 <dt>
476 --numstat
477 </dt>
478 <dd>
480 Similar to --stat, but shows number of added and
481 deleted lines in decimal notation and pathname without
482 abbreviation, to make it more machine friendly. For
483 binary files, outputs two <tt>-</tt> instead of saying
484 <tt>0 0</tt>.
485 </p>
486 </dd>
487 <dt>
488 --shortstat
489 </dt>
490 <dd>
492 Output only the last line of the --stat format containing total
493 number of modified files, as well as number of added and deleted
494 lines.
495 </p>
496 </dd>
497 <dt>
498 --dirstat[=limit]
499 </dt>
500 <dd>
502 Output the distribution of relative amount of changes (number of lines added or
503 removed) for each sub-directory. Directories with changes below
504 a cut-off percent (3% by default) are not shown. The cut-off percent
505 can be set with "--dirstat=limit". Changes in a child directory is not
506 counted for the parent directory, unless "--cumulative" is used.
507 </p>
508 </dd>
509 <dt>
510 --dirstat-by-file[=limit]
511 </dt>
512 <dd>
514 Same as --dirstat, but counts changed files instead of lines.
515 </p>
516 </dd>
517 <dt>
518 --summary
519 </dt>
520 <dd>
522 Output a condensed summary of extended header information
523 such as creations, renames and mode changes.
524 </p>
525 </dd>
526 <dt>
527 --patch-with-stat
528 </dt>
529 <dd>
531 Synonym for "-p --stat".
533 </p>
534 </dd>
535 <dt>
537 </dt>
538 <dd>
540 NUL-line termination on output. This affects the --raw
541 output field terminator. Also output from commands such
542 as "git-log" will be delimited with NUL between commits.
543 </p>
544 </dd>
545 <dt>
546 --name-only
547 </dt>
548 <dd>
550 Show only names of changed files.
551 </p>
552 </dd>
553 <dt>
554 --name-status
555 </dt>
556 <dd>
558 Show only names and status of changed files. See the description
559 of the <tt>--diff-filter</tt> option on what the status letters mean.
560 </p>
561 </dd>
562 <dt>
563 --color
564 </dt>
565 <dd>
567 Show colored diff.
568 </p>
569 </dd>
570 <dt>
571 --no-color
572 </dt>
573 <dd>
575 Turn off colored diff, even when the configuration file
576 gives the default to color output.
577 </p>
578 </dd>
579 <dt>
580 --color-words[=&lt;regex&gt;]
581 </dt>
582 <dd>
584 Show colored word diff, i.e., color words which have changed.
585 By default, words are separated by whitespace.
586 </p>
587 <div class="para"><p>When a &lt;regex&gt; is specified, every non-overlapping match of the
588 &lt;regex&gt; is considered a word. Anything between these matches is
589 considered whitespace and ignored(!) for the purposes of finding
590 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
591 expression to make sure that it matches all non-whitespace characters.
592 A match that contains a newline is silently truncated(!) at the
593 newline.</p></div>
594 <div class="para"><p>The regex can also be set via a diff driver or configuration option, see
595 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
596 overrides any diff driver or configuration setting. Diff drivers
597 override configuration settings.</p></div>
598 </dd>
599 <dt>
600 --no-renames
601 </dt>
602 <dd>
604 Turn off rename detection, even when the configuration
605 file gives the default to do so.
606 </p>
607 </dd>
608 <dt>
609 --check
610 </dt>
611 <dd>
613 Warn if changes introduce trailing whitespace
614 or an indent that uses a space before a tab. Exits with
615 non-zero status if problems are found. Not compatible with
616 --exit-code.
617 </p>
618 </dd>
619 <dt>
620 --full-index
621 </dt>
622 <dd>
624 Instead of the first handful of characters, show the full
625 pre- and post-image blob object names on the "index"
626 line when generating patch format output.
627 </p>
628 </dd>
629 <dt>
630 --binary
631 </dt>
632 <dd>
634 In addition to --full-index, output "binary diff" that
635 can be applied with "git apply".
636 </p>
637 </dd>
638 <dt>
639 --abbrev[=&lt;n&gt;]
640 </dt>
641 <dd>
643 Instead of showing the full 40-byte hexadecimal object
644 name in diff-raw format output and diff-tree header
645 lines, show only a partial prefix. This is
646 independent of --full-index option above, which controls
647 the diff-patch output format. Non default number of
648 digits can be specified with --abbrev=&lt;n&gt;.
649 </p>
650 </dd>
651 <dt>
653 </dt>
654 <dd>
656 Break complete rewrite changes into pairs of delete and create.
657 </p>
658 </dd>
659 <dt>
661 </dt>
662 <dd>
664 Detect renames.
665 </p>
666 </dd>
667 <dt>
669 </dt>
670 <dd>
672 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
673 </p>
674 </dd>
675 <dt>
676 --diff-filter=[ACDMRTUXB*]
677 </dt>
678 <dd>
680 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
681 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
682 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
683 are Unmerged (<tt>U</tt>), are
684 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
685 Any combination of the filter characters may be used.
686 When <tt>*</tt> (All-or-none) is added to the combination, all
687 paths are selected if there is any file that matches
688 other criteria in the comparison; if there is no file
689 that matches other criteria, nothing is selected.
690 </p>
691 </dd>
692 <dt>
693 --find-copies-harder
694 </dt>
695 <dd>
697 For performance reasons, by default, <tt>-C</tt> option finds copies only
698 if the original file of the copy was modified in the same
699 changeset. This flag makes the command
700 inspect unmodified files as candidates for the source of
701 copy. This is a very expensive operation for large
702 projects, so use it with caution. Giving more than one
703 <tt>-C</tt> option has the same effect.
704 </p>
705 </dd>
706 <dt>
707 -l&lt;num&gt;
708 </dt>
709 <dd>
711 -M and -C options require O(n^2) processing time where n
712 is the number of potential rename/copy targets. This
713 option prevents rename/copy detection from running if
714 the number of rename/copy targets exceeds the specified
715 number.
716 </p>
717 </dd>
718 <dt>
719 -S&lt;string&gt;
720 </dt>
721 <dd>
723 Look for differences that introduce or remove an instance of
724 &lt;string&gt;. Note that this is different than the string simply
725 appearing in diff output; see the <em>pickaxe</em> entry in
726 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
727 </p>
728 </dd>
729 <dt>
730 --pickaxe-all
731 </dt>
732 <dd>
734 When -S finds a change, show all the changes in that
735 changeset, not just the files that contain the change
736 in &lt;string&gt;.
737 </p>
738 </dd>
739 <dt>
740 --pickaxe-regex
741 </dt>
742 <dd>
744 Make the &lt;string&gt; not a plain string but an extended POSIX
745 regex to match.
746 </p>
747 </dd>
748 <dt>
749 -O&lt;orderfile&gt;
750 </dt>
751 <dd>
753 Output the patch in the order specified in the
754 &lt;orderfile&gt;, which has one shell glob pattern per line.
755 </p>
756 </dd>
757 <dt>
759 </dt>
760 <dd>
762 Swap two inputs; that is, show differences from index or
763 on-disk file to tree contents.
764 </p>
765 </dd>
766 <dt>
767 --relative[=&lt;path&gt;]
768 </dt>
769 <dd>
771 When run from a subdirectory of the project, it can be
772 told to exclude changes outside the directory and show
773 pathnames relative to it with this option. When you are
774 not in a subdirectory (e.g. in a bare repository), you
775 can name which subdirectory to make the output relative
776 to by giving a &lt;path&gt; as an argument.
777 </p>
778 </dd>
779 <dt>
781 </dt>
782 <dt>
783 --text
784 </dt>
785 <dd>
787 Treat all files as text.
788 </p>
789 </dd>
790 <dt>
791 --ignore-space-at-eol
792 </dt>
793 <dd>
795 Ignore changes in whitespace at EOL.
796 </p>
797 </dd>
798 <dt>
800 </dt>
801 <dt>
802 --ignore-space-change
803 </dt>
804 <dd>
806 Ignore changes in amount of whitespace. This ignores whitespace
807 at line end, and considers all other sequences of one or
808 more whitespace characters to be equivalent.
809 </p>
810 </dd>
811 <dt>
813 </dt>
814 <dt>
815 --ignore-all-space
816 </dt>
817 <dd>
819 Ignore whitespace when comparing lines. This ignores
820 differences even if one line has whitespace where the other
821 line has none.
822 </p>
823 </dd>
824 <dt>
825 --inter-hunk-context=&lt;lines&gt;
826 </dt>
827 <dd>
829 Show the context between diff hunks, up to the specified number
830 of lines, thereby fusing hunks that are close to each other.
831 </p>
832 </dd>
833 <dt>
834 --exit-code
835 </dt>
836 <dd>
838 Make the program exit with codes similar to diff(1).
839 That is, it exits with 1 if there were differences and
840 0 means no differences.
841 </p>
842 </dd>
843 <dt>
844 --quiet
845 </dt>
846 <dd>
848 Disable all output of the program. Implies --exit-code.
849 </p>
850 </dd>
851 <dt>
852 --ext-diff
853 </dt>
854 <dd>
856 Allow an external diff helper to be executed. If you set an
857 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
858 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
859 </p>
860 </dd>
861 <dt>
862 --no-ext-diff
863 </dt>
864 <dd>
866 Disallow external diff drivers.
867 </p>
868 </dd>
869 <dt>
870 --ignore-submodules
871 </dt>
872 <dd>
874 Ignore changes to submodules in the diff generation.
875 </p>
876 </dd>
877 <dt>
878 --src-prefix=&lt;prefix&gt;
879 </dt>
880 <dd>
882 Show the given source prefix instead of "a/".
883 </p>
884 </dd>
885 <dt>
886 --dst-prefix=&lt;prefix&gt;
887 </dt>
888 <dd>
890 Show the given destination prefix instead of "b/".
891 </p>
892 </dd>
893 <dt>
894 --no-prefix
895 </dt>
896 <dd>
898 Do not show any source or destination prefix.
899 </p>
900 </dd>
901 </dl></div>
902 <div class="para"><p>For more detailed explanation on these common options, see also
903 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
904 <div class="vlist"><dl>
905 <dt>
906 &lt;path&gt;&#8230;
907 </dt>
908 <dd>
910 The &lt;paths&gt; parameters, when given, are used to limit
911 the diff to the named paths (you can give directory
912 names and get diff for all files under them).
913 </p>
914 </dd>
915 </dl></div>
916 </div>
917 <h2 id="_output_format">Output format</h2>
918 <div class="sectionbody">
919 <div class="para"><p>The output format from "git-diff-index", "git-diff-tree",
920 "git-diff-files" and "git diff --raw" are very similar.</p></div>
921 <div class="para"><p>These commands all compare two sets of things; what is
922 compared differs:</p></div>
923 <div class="vlist"><dl>
924 <dt>
925 git-diff-index &lt;tree-ish&gt;
926 </dt>
927 <dd>
929 compares the &lt;tree-ish&gt; and the files on the filesystem.
930 </p>
931 </dd>
932 <dt>
933 git-diff-index --cached &lt;tree-ish&gt;
934 </dt>
935 <dd>
937 compares the &lt;tree-ish&gt; and the index.
938 </p>
939 </dd>
940 <dt>
941 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
942 </dt>
943 <dd>
945 compares the trees named by the two arguments.
946 </p>
947 </dd>
948 <dt>
949 git-diff-files [&lt;pattern&gt;&#8230;]
950 </dt>
951 <dd>
953 compares the index and the files on the filesystem.
954 </p>
955 </dd>
956 </dl></div>
957 <div class="para"><p>An output line is formatted this way:</p></div>
958 <div class="listingblock">
959 <div class="content">
960 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
961 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
962 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
963 create :000000 100644 0000000... 1234567... A file4
964 delete :100644 000000 1234567... 0000000... D file5
965 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
966 </div></div>
967 <div class="para"><p>That is, from the left to the right:</p></div>
968 <div class="olist"><ol>
969 <li>
971 a colon.
972 </p>
973 </li>
974 <li>
976 mode for "src"; 000000 if creation or unmerged.
977 </p>
978 </li>
979 <li>
981 a space.
982 </p>
983 </li>
984 <li>
986 mode for "dst"; 000000 if deletion or unmerged.
987 </p>
988 </li>
989 <li>
991 a space.
992 </p>
993 </li>
994 <li>
996 sha1 for "src"; 0{40} if creation or unmerged.
997 </p>
998 </li>
999 <li>
1001 a space.
1002 </p>
1003 </li>
1004 <li>
1006 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1007 </p>
1008 </li>
1009 <li>
1011 a space.
1012 </p>
1013 </li>
1014 <li>
1016 status, followed by optional "score" number.
1017 </p>
1018 </li>
1019 <li>
1021 a tab or a NUL when <em>-z</em> option is used.
1022 </p>
1023 </li>
1024 <li>
1026 path for "src"
1027 </p>
1028 </li>
1029 <li>
1031 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1032 </p>
1033 </li>
1034 <li>
1036 path for "dst"; only exists for C or R.
1037 </p>
1038 </li>
1039 <li>
1041 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1042 </p>
1043 </li>
1044 </ol></div>
1045 <div class="para"><p>Possible status letters are:</p></div>
1046 <div class="ilist"><ul>
1047 <li>
1049 A: addition of a file
1050 </p>
1051 </li>
1052 <li>
1054 C: copy of a file into a new one
1055 </p>
1056 </li>
1057 <li>
1059 D: deletion of a file
1060 </p>
1061 </li>
1062 <li>
1064 M: modification of the contents or mode of a file
1065 </p>
1066 </li>
1067 <li>
1069 R: renaming of a file
1070 </p>
1071 </li>
1072 <li>
1074 T: change in the type of the file
1075 </p>
1076 </li>
1077 <li>
1079 U: file is unmerged (you must complete the merge before it can
1080 be committed)
1081 </p>
1082 </li>
1083 <li>
1085 X: "unknown" change type (most probably a bug, please report it)
1086 </p>
1087 </li>
1088 </ul></div>
1089 <div class="para"><p>Status letters C and R are always followed by a score (denoting the
1090 percentage of similarity between the source and target of the move or
1091 copy), and are the only ones to be so.</p></div>
1092 <div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1093 and it is out of sync with the index.</p></div>
1094 <div class="para"><p>Example:</p></div>
1095 <div class="listingblock">
1096 <div class="content">
1097 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1098 </div></div>
1099 <div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1100 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1101 respectively.</p></div>
1102 </div>
1103 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1104 <div class="sectionbody">
1105 <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1106 can take <em>-c</em> or <em>--cc</em> option
1107 to generate diff output also for merge commits. The output differs
1108 from the format described above in the following way:</p></div>
1109 <div class="olist"><ol>
1110 <li>
1112 there is a colon for each parent
1113 </p>
1114 </li>
1115 <li>
1117 there are more "src" modes and "src" sha1
1118 </p>
1119 </li>
1120 <li>
1122 status is concatenated status characters for each parent
1123 </p>
1124 </li>
1125 <li>
1127 no optional "score" number
1128 </p>
1129 </li>
1130 <li>
1132 single path, only for "dst"
1133 </p>
1134 </li>
1135 </ol></div>
1136 <div class="para"><p>Example:</p></div>
1137 <div class="listingblock">
1138 <div class="content">
1139 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1140 </div></div>
1141 <div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1142 all parents.</p></div>
1143 </div>
1144 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1145 <div class="sectionbody">
1146 <div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1147 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1148 "git log" with the "-p" option, they
1149 do not produce the output described above; instead they produce a
1150 patch file. You can customize the creation of such patches via the
1151 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1152 <div class="para"><p>What the -p option produces is slightly different from the traditional
1153 diff format.</p></div>
1154 <div class="olist"><ol>
1155 <li>
1157 It is preceded with a "git diff" header, that looks like
1158 this:
1159 </p>
1160 <div class="literalblock">
1161 <div class="content">
1162 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1163 </div></div>
1164 <div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1165 involved. Especially, even for a creation or a deletion,
1166 <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1167 <div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1168 name of the source file of the rename/copy and the name of
1169 the file that rename/copy produces, respectively.</p></div>
1170 </li>
1171 <li>
1173 It is followed by one or more extended header lines:
1174 </p>
1175 <div class="literalblock">
1176 <div class="content">
1177 <pre><tt>old mode &lt;mode&gt;
1178 new mode &lt;mode&gt;
1179 deleted file mode &lt;mode&gt;
1180 new file mode &lt;mode&gt;
1181 copy from &lt;path&gt;
1182 copy to &lt;path&gt;
1183 rename from &lt;path&gt;
1184 rename to &lt;path&gt;
1185 similarity index &lt;number&gt;
1186 dissimilarity index &lt;number&gt;
1187 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1188 </div></div>
1189 </li>
1190 <li>
1192 TAB, LF, double quote and backslash characters in pathnames
1193 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1194 If there is need for such substitution then the whole
1195 pathname is put in double quotes.
1196 </p>
1197 </li>
1198 </ol></div>
1199 <div class="para"><p>The similarity index is the percentage of unchanged lines, and
1200 the dissimilarity index is the percentage of changed lines. It
1201 is a rounded down integer, followed by a percent sign. The
1202 similarity index value of 100% is thus reserved for two equal
1203 files, while 100% dissimilarity means that no line from the old
1204 file made it into the new one.</p></div>
1205 </div>
1206 <h2 id="_combined_diff_format">combined diff format</h2>
1207 <div class="sectionbody">
1208 <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
1209 <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1210 with "git log -p", this is the default format.
1211 A <em>combined diff</em> format looks like this:</p></div>
1212 <div class="listingblock">
1213 <div class="content">
1214 <pre><tt>diff --combined describe.c
1215 index fabadb8,cc95eb0..4866510
1216 --- a/describe.c
1217 +++ b/describe.c
1218 @@@ -98,20 -98,12 +98,20 @@@
1219 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1222 - static void describe(char *arg)
1223 -static void describe(struct commit *cmit, int last_one)
1224 ++static void describe(char *arg, int last_one)
1226 + unsigned char sha1[20];
1227 + struct commit *cmit;
1228 struct commit_list *list;
1229 static int initialized = 0;
1230 struct commit_name *n;
1232 + if (get_sha1(arg, sha1) &lt; 0)
1233 + usage(describe_usage);
1234 + cmit = lookup_commit_reference(sha1);
1235 + if (!cmit)
1236 + usage(describe_usage);
1238 if (!initialized) {
1239 initialized = 1;
1240 for_each_ref(get_name);</tt></pre>
1241 </div></div>
1242 <div class="olist"><ol>
1243 <li>
1245 It is preceded with a "git diff" header, that looks like
1246 this (when <em>-c</em> option is used):
1247 </p>
1248 <div class="literalblock">
1249 <div class="content">
1250 <pre><tt>diff --combined file</tt></pre>
1251 </div></div>
1252 <div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
1253 <div class="literalblock">
1254 <div class="content">
1255 <pre><tt>diff --cc file</tt></pre>
1256 </div></div>
1257 </li>
1258 <li>
1260 It is followed by one or more extended header lines
1261 (this example shows a merge with two parents):
1262 </p>
1263 <div class="literalblock">
1264 <div class="content">
1265 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1266 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1267 new file mode &lt;mode&gt;
1268 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1269 </div></div>
1270 <div class="para"><p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
1271 the &lt;mode&gt; is different from the rest. Extended headers with
1272 information about detected contents movement (renames and
1273 copying detection) are designed to work with diff of two
1274 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1275 </li>
1276 <li>
1278 It is followed by two-line from-file/to-file header
1279 </p>
1280 <div class="literalblock">
1281 <div class="content">
1282 <pre><tt>--- a/file
1283 +++ b/file</tt></pre>
1284 </div></div>
1285 <div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
1286 format, <tt>/dev/null</tt> is used to signal created or deleted
1287 files.</p></div>
1288 </li>
1289 <li>
1291 Chunk header format is modified to prevent people from
1292 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1293 was created for review of merge commit changes, and was not
1294 meant for apply. The change is similar to the change in the
1295 extended <em>index</em> header:
1296 </p>
1297 <div class="literalblock">
1298 <div class="content">
1299 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1300 </div></div>
1301 <div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1302 header for combined diff format.</p></div>
1303 </li>
1304 </ol></div>
1305 <div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1306 files A and B with a single column that has <tt>-</tt> (minus &#8212;
1307 appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
1308 added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
1309 compares two or more files file1, file2,&#8230; with one file X, and
1310 shows how X differs from each of fileN. One column for each of
1311 fileN is prepended to the output line to note how X's line is
1312 different from it.</p></div>
1313 <div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in
1314 fileN but it does not appear in the result. A <tt>+</tt> character
1315 in the column N means that the line appears in the result,
1316 and fileN does not have that line (in other words, the line was
1317 added, from the point of view of that parent).</p></div>
1318 <div class="para"><p>In the above example output, the function signature was changed
1319 from both files (hence two <tt>-</tt> removals from both file1 and
1320 file2, plus <tt>++</tt> to mean one line that was added does not appear
1321 in either file1 nor file2). Also eight other lines are the same
1322 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1323 <div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1324 merge commit with the merge result (i.e. file1..fileN are the
1325 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1326 two unresolved merge parents with the working tree file
1327 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1328 "their version").</p></div>
1329 </div>
1330 <h2 id="_other_diff_formats">other diff formats</h2>
1331 <div class="sectionbody">
1332 <div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1333 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1334 output. These options can be combined with other options, such as
1335 <tt>-p</tt>, and are meant for human consumption.</p></div>
1336 <div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1337 formats the pathnames compactly by combining common prefix and suffix of
1338 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1339 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1340 <div class="listingblock">
1341 <div class="content">
1342 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1343 </div></div>
1344 <div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1345 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1346 like this:</p></div>
1347 <div class="listingblock">
1348 <div class="content">
1349 <pre><tt>1 2 README
1350 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1351 </div></div>
1352 <div class="para"><p>That is, from left to right:</p></div>
1353 <div class="olist"><ol>
1354 <li>
1356 the number of added lines;
1357 </p>
1358 </li>
1359 <li>
1361 a tab;
1362 </p>
1363 </li>
1364 <li>
1366 the number of deleted lines;
1367 </p>
1368 </li>
1369 <li>
1371 a tab;
1372 </p>
1373 </li>
1374 <li>
1376 pathname (possibly with rename/copy information);
1377 </p>
1378 </li>
1379 <li>
1381 a newline.
1382 </p>
1383 </li>
1384 </ol></div>
1385 <div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1386 <div class="listingblock">
1387 <div class="content">
1388 <pre><tt>1 2 README NUL
1389 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1390 </div></div>
1391 <div class="para"><p>That is:</p></div>
1392 <div class="olist"><ol>
1393 <li>
1395 the number of added lines;
1396 </p>
1397 </li>
1398 <li>
1400 a tab;
1401 </p>
1402 </li>
1403 <li>
1405 the number of deleted lines;
1406 </p>
1407 </li>
1408 <li>
1410 a tab;
1411 </p>
1412 </li>
1413 <li>
1415 a NUL (only exists if renamed/copied);
1416 </p>
1417 </li>
1418 <li>
1420 pathname in preimage;
1421 </p>
1422 </li>
1423 <li>
1425 a NUL (only exists if renamed/copied);
1426 </p>
1427 </li>
1428 <li>
1430 pathname in postimage (only exists if renamed/copied);
1431 </p>
1432 </li>
1433 <li>
1435 a NUL.
1436 </p>
1437 </li>
1438 </ol></div>
1439 <div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1440 scripts that read the output to tell if the current record being read is
1441 a single-path record or a rename/copy record without reading ahead.
1442 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1443 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1444 </div>
1445 <h2 id="_examples">EXAMPLES</h2>
1446 <div class="sectionbody">
1447 <div class="vlist"><dl>
1448 <dt>
1449 Various ways to check your working tree
1450 </dt>
1451 <dd>
1452 <div class="listingblock">
1453 <div class="content">
1454 <pre><tt>$ git diff <b>(1)</b>
1455 $ git diff --cached <b>(2)</b>
1456 $ git diff HEAD <b>(3)</b></tt></pre>
1457 </div></div>
1458 <div class="colist"><ol>
1459 <li>
1461 Changes in the working tree not yet staged for the next commit.
1462 </p>
1463 </li>
1464 <li>
1466 Changes between the index and your last commit; what you
1467 would be committing if you run "git commit" without "-a" option.
1468 </p>
1469 </li>
1470 <li>
1472 Changes in the working tree since your last commit; what you
1473 would be committing if you run "git commit -a"
1474 </p>
1475 </li>
1476 </ol></div>
1477 </dd>
1478 <dt>
1479 Comparing with arbitrary commits
1480 </dt>
1481 <dd>
1482 <div class="listingblock">
1483 <div class="content">
1484 <pre><tt>$ git diff test <b>(1)</b>
1485 $ git diff HEAD -- ./test <b>(2)</b>
1486 $ git diff HEAD^ HEAD <b>(3)</b></tt></pre>
1487 </div></div>
1488 <div class="colist"><ol>
1489 <li>
1491 Instead of using the tip of the current branch, compare with the
1492 tip of "test" branch.
1493 </p>
1494 </li>
1495 <li>
1497 Instead of comparing with the tip of "test" branch, compare with
1498 the tip of the current branch, but limit the comparison to the
1499 file "test".
1500 </p>
1501 </li>
1502 <li>
1504 Compare the version before the last commit and the last commit.
1505 </p>
1506 </li>
1507 </ol></div>
1508 </dd>
1509 <dt>
1510 Comparing branches
1511 </dt>
1512 <dd>
1513 <div class="listingblock">
1514 <div class="content">
1515 <pre><tt>$ git diff topic master <b>(1)</b>
1516 $ git diff topic..master <b>(2)</b>
1517 $ git diff topic...master <b>(3)</b></tt></pre>
1518 </div></div>
1519 <div class="colist"><ol>
1520 <li>
1522 Changes between the tips of the topic and the master branches.
1523 </p>
1524 </li>
1525 <li>
1527 Same as above.
1528 </p>
1529 </li>
1530 <li>
1532 Changes that occurred on the master branch since when the topic
1533 branch was started off it.
1534 </p>
1535 </li>
1536 </ol></div>
1537 </dd>
1538 <dt>
1539 Limiting the diff output
1540 </dt>
1541 <dd>
1542 <div class="listingblock">
1543 <div class="content">
1544 <pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>
1545 $ git diff --name-status <b>(2)</b>
1546 $ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>
1547 </div></div>
1548 <div class="colist"><ol>
1549 <li>
1551 Show only modification, rename and copy, but not addition
1552 nor deletion.
1553 </p>
1554 </li>
1555 <li>
1557 Show only names and the nature of change, but not actual
1558 diff output.
1559 </p>
1560 </li>
1561 <li>
1563 Limit diff output to named subtrees.
1564 </p>
1565 </li>
1566 </ol></div>
1567 </dd>
1568 <dt>
1569 Munging the diff output
1570 </dt>
1571 <dd>
1572 <div class="listingblock">
1573 <div class="content">
1574 <pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>
1575 $ git diff -R <b>(2)</b></tt></pre>
1576 </div></div>
1577 <div class="colist"><ol>
1578 <li>
1580 Spend extra cycles to find renames, copies and complete
1581 rewrites (very expensive).
1582 </p>
1583 </li>
1584 <li>
1586 Output diff in reverse.
1587 </p>
1588 </li>
1589 </ol></div>
1590 </dd>
1591 </dl></div>
1592 </div>
1593 <h2 id="_author">Author</h2>
1594 <div class="sectionbody">
1595 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
1596 </div>
1597 <h2 id="_documentation">Documentation</h2>
1598 <div class="sectionbody">
1599 <div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
1600 </div>
1601 <h2 id="_git">GIT</h2>
1602 <div class="sectionbody">
1603 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1604 </div>
1605 <div id="footer">
1606 <div id="footer-text">
1607 Last updated 2009-04-02 06:49:50 UTC
1608 </div>
1609 </div>
1610 </body>
1611 </html>