blob: 585729d692305c6e94ada6bb9da8ae325170648c [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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" />
Junio C Hamano6ec31b92006-02-10 05:52:016<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff-files(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-files(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-files -
269 Compares files in the working tree and the index
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano9882a522007-04-27 08:22:22275<p><em>git-diff-files</em> [-q] [-0|-1|-2|-3|-c|--cc|--no-index] [&lt;common diff options&gt;] [&lt;path&gt;&#8230;]</p>
Junio C Hamano1a4e8412005-12-27 08:17:23276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
279<p>Compares the files in the working tree and the index. When paths
280are specified, compares only those named paths. Otherwise all
281entries in the index are compared. The output format is the
282same as "git-diff-index" and "git-diff-tree".</p>
283</div>
284<h2>OPTIONS</h2>
285<div class="sectionbody">
286<dl>
287<dt>
288-p
289</dt>
290<dd>
291<p>
Junio C Hamanoff979792007-11-16 10:11:30292 Generate patch (see section on generating patches).
293
Junio C Hamano1a4e8412005-12-27 08:17:23294</p>
295</dd>
296<dt>
297-u
298</dt>
299<dd>
300<p>
301 Synonym for "-p".
302</p>
303</dd>
304<dt>
Junio C Hamano69361562007-07-26 02:14:34305-U&lt;n&gt;
306</dt>
307<dd>
308<p>
309 Shorthand for "--unified=&lt;n&gt;".
310</p>
311</dd>
312<dt>
313--unified=&lt;n&gt;
314</dt>
315<dd>
316<p>
317 Generate diffs with &lt;n&gt; lines of context instead of
318 the usual three. Implies "-p".
319</p>
320</dd>
321<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34322--raw
323</dt>
324<dd>
325<p>
326 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30327 This is the default.
Junio C Hamano9ae1a062006-07-10 08:12:34328</p>
329</dd>
330<dt>
Junio C Hamano54559c82006-04-13 07:45:12331--patch-with-raw
332</dt>
333<dd>
334<p>
Junio C Hamano9ae1a062006-07-10 08:12:34335 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12336</p>
337</dd>
338<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29339--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42340</dt>
341<dd>
342<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29343 Generate a diffstat. You can override the default
344 output width for 80-column terminal by "--stat=width".
345 The width of the filename part can be controlled by
346 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42347</p>
348</dd>
349<dt>
Junio C Hamanofbe00522006-10-19 05:58:48350--numstat
351</dt>
352<dd>
353<p>
354 Similar to --stat, but shows number of added and
355 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43356 abbreviation, to make it more machine friendly. For
357 binary files, outputs two <tt>-</tt> instead of saying
358 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48359</p>
360</dd>
361<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04362--shortstat
363</dt>
364<dd>
365<p>
366 Output only the last line of the --stat format containing total
367 number of modified files, as well as number of added and deleted
368 lines.
369</p>
370</dd>
371<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11372--summary
373</dt>
374<dd>
375<p>
376 Output a condensed summary of extended header information
377 such as creations, renames and mode changes.
378</p>
379</dd>
380<dt>
Junio C Hamanod1308c92006-04-16 11:01:09381--patch-with-stat
382</dt>
383<dd>
384<p>
Junio C Hamano9ae1a062006-07-10 08:12:34385 Synonym for "-p --stat".
Junio C Hamanoff979792007-11-16 10:11:30386
Junio C Hamanod1308c92006-04-16 11:01:09387</p>
388</dd>
389<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23390-z
391</dt>
392<dd>
393<p>
Junio C Hamanob968dbb2007-07-27 07:26:40394 NUL-line termination on output. This affects the --raw
395 output field terminator. Also output from commands such
396 as "git-log" will be delimited with NUL between commits.
Junio C Hamano1a4e8412005-12-27 08:17:23397</p>
398</dd>
399<dt>
400--name-only
401</dt>
402<dd>
403<p>
404 Show only names of changed files.
405</p>
406</dd>
407<dt>
408--name-status
409</dt>
410<dd>
411<p>
412 Show only names and status of changed files.
413</p>
414</dd>
415<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34416--color
417</dt>
418<dd>
419<p>
420 Show colored diff.
421</p>
422</dd>
423<dt>
424--no-color
425</dt>
426<dd>
427<p>
428 Turn off colored diff, even when the configuration file
429 gives the default to color output.
430</p>
431</dd>
432<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41433--color-words
434</dt>
435<dd>
436<p>
437 Show colored word diff, i.e. color words which have changed.
438</p>
439</dd>
440<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34441--no-renames
442</dt>
443<dd>
444<p>
445 Turn off rename detection, even when the configuration
446 file gives the default to do so.
447</p>
448</dd>
449<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21450--check
451</dt>
452<dd>
453<p>
454 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54455 or an indent that uses a space before a tab. Exits with
456 non-zero status if problems are found. Not compatible with
457 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21458</p>
459</dd>
460<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23461--full-index
462</dt>
463<dd>
464<p>
465 Instead of the first handful characters, show full
466 object name of pre- and post-image blob on the "index"
467 line when generating a patch format output.
468</p>
469</dd>
470<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34471--binary
472</dt>
473<dd>
474<p>
475 In addition to --full-index, output "binary diff" that
476 can be applied with "git apply".
477</p>
478</dd>
479<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23480--abbrev[=&lt;n&gt;]
481</dt>
482<dd>
483<p>
484 Instead of showing the full 40-byte hexadecimal object
485 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58486 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23487 independent of --full-index option above, which controls
488 the diff-patch output format. Non default number of
489 digits can be specified with --abbrev=&lt;n&gt;.
490</p>
491</dd>
492<dt>
493-B
494</dt>
495<dd>
496<p>
497 Break complete rewrite changes into pairs of delete and create.
498</p>
499</dd>
500<dt>
501-M
502</dt>
503<dd>
504<p>
505 Detect renames.
506</p>
507</dd>
508<dt>
509-C
510</dt>
511<dd>
512<p>
Junio C Hamano16f98872007-06-12 16:09:14513 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23514</p>
515</dd>
516<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01517--diff-filter=[ACDMRTUXB*]
518</dt>
519<dd>
520<p>
521 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
522 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
523 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
524 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
525 Any combination of the filter characters may be used.
526 When <tt>*</tt> (All-or-none) is added to the combination, all
527 paths are selected if there is any file that matches
528 other criteria in the comparison; if there is no file
529 that matches other criteria, nothing is selected.
530</p>
531</dd>
532<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23533--find-copies-harder
534</dt>
535<dd>
536<p>
Junio C Hamano16f98872007-06-12 16:09:14537 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23538 if the original file of the copy was modified in the same
539 changeset. This flag makes the command
540 inspect unmodified files as candidates for the source of
541 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14542 projects, so use it with caution. Giving more than one
543 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23544</p>
545</dd>
546<dt>
547-l&lt;num&gt;
548</dt>
549<dd>
550<p>
551 -M and -C options require O(n^2) processing time where n
552 is the number of potential rename/copy targets. This
553 option prevents rename/copy detection from running if
554 the number of rename/copy targets exceeds the specified
555 number.
556</p>
557</dd>
558<dt>
559-S&lt;string&gt;
560</dt>
561<dd>
562<p>
563 Look for differences that contain the change in &lt;string&gt;.
564</p>
565</dd>
566<dt>
567--pickaxe-all
568</dt>
569<dd>
570<p>
571 When -S finds a change, show all the changes in that
572 changeset, not just the files that contain the change
573 in &lt;string&gt;.
574</p>
575</dd>
576<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28577--pickaxe-regex
578</dt>
579<dd>
580<p>
581 Make the &lt;string&gt; not a plain string but an extended POSIX
582 regex to match.
583</p>
584</dd>
585<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23586-O&lt;orderfile&gt;
587</dt>
588<dd>
589<p>
590 Output the patch in the order specified in the
591 &lt;orderfile&gt;, which has one shell glob pattern per line.
592</p>
593</dd>
594<dt>
595-R
596</dt>
597<dd>
598<p>
599 Swap two inputs; that is, show differences from index or
600 on-disk file to tree contents.
601</p>
602</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14603<dt>
604--text
605</dt>
606<dd>
607<p>
608 Treat all files as text.
609</p>
610</dd>
611<dt>
612-a
613</dt>
614<dd>
615<p>
616 Shorthand for "--text".
617</p>
618</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07619<dt>
Junio C Hamanofd468962007-02-14 23:45:04620--ignore-space-at-eol
621</dt>
622<dd>
623<p>
Junio C Hamano3a702342007-12-12 21:34:02624 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04625</p>
626</dd>
627<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07628--ignore-space-change
629</dt>
630<dd>
631<p>
Junio C Hamano3a702342007-12-12 21:34:02632 Ignore changes in amount of whitespace. This ignores whitespace
633 at line end, and considers all other sequences of one or
634 more whitespace characters to be equivalent.
Junio C Hamanod9c2d2f2006-12-06 08:59:07635</p>
636</dd>
637<dt>
638-b
639</dt>
640<dd>
641<p>
642 Shorthand for "--ignore-space-change".
643</p>
644</dd>
645<dt>
646--ignore-all-space
647</dt>
648<dd>
649<p>
Junio C Hamano3a702342007-12-12 21:34:02650 Ignore whitespace when comparing lines. This ignores
651 differences even if one line has whitespace where the other
Junio C Hamanod9c2d2f2006-12-06 08:59:07652 line has none.
653</p>
654</dd>
655<dt>
656-w
657</dt>
658<dd>
659<p>
660 Shorthand for "--ignore-all-space".
661</p>
662</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30663<dt>
664--exit-code
665</dt>
666<dd>
667<p>
668 Make the program exit with codes similar to diff(1).
669 That is, it exits with 1 if there were differences and
670 0 means no differences.
671</p>
672</dd>
Junio C Hamano35e57552007-03-25 07:54:35673<dt>
674--quiet
675</dt>
676<dd>
677<p>
678 Disable all output of the program. Implies --exit-code.
679</p>
680</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40681<dt>
682--ext-diff
683</dt>
684<dd>
685<p>
686 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53687 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
688 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40689</p>
690</dd>
691<dt>
692--no-ext-diff
693</dt>
694<dd>
695<p>
696 Disallow external diff drivers.
697</p>
698</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33699<dt>
700--src-prefix=&lt;prefix&gt;
701</dt>
702<dd>
703<p>
704 Show the given source prefix instead of "a/".
705</p>
706</dd>
707<dt>
708--dst-prefix=&lt;prefix&gt;
709</dt>
710<dd>
711<p>
712 Show the given destination prefix instead of "b/".
713</p>
714</dd>
715<dt>
716--no-prefix
717</dt>
718<dd>
719<p>
720 Do not show any source or destination prefix.
721</p>
722</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23723</dl>
724<p>For more detailed explanation on these common options, see also
725<a href="diffcore.html">diffcore documentation</a>.</p>
726<dl>
727<dt>
728-1 -2 -3 or --base --ours --theirs, and -0
729</dt>
730<dd>
731<p>
732 Diff against the "base" version, "our branch" or "their
733 branch" respectively. With these options, diffs for
734 merged entries are not shown.
735</p>
736<p>The default is to diff against our branch (-2) and the
737cleanly resolved paths. The option -0 can be given to
738omit diff output for unmerged entries and just show "Unmerged".</p>
739</dd>
740<dt>
Junio C Hamanofb56a962006-01-28 10:38:19741-c,--cc
742</dt>
743<dd>
744<p>
745 This compares stage 2 (our branch), stage 3 (their
746 branch) and the working tree file and outputs a combined
747 diff, similar to the way <em>diff-tree</em> shows a merge
748 commit with these flags.
749</p>
750</dd>
751<dt>
Junio C Hamano9882a522007-04-27 08:22:22752--no-index
Junio C Hamanodb911ee2007-02-28 08:13:52753</dt>
754<dd>
755<p>
756 Compare the two given files / directories.
757</p>
758</dd>
759<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23760-q
761</dt>
762<dd>
763<p>
Junio C Hamano51c2ab02006-07-09 20:38:54764 Remain silent even on nonexistent files
Junio C Hamano1a4e8412005-12-27 08:17:23765</p>
766</dd>
767</dl>
768</div>
769<h2>Output format</h2>
770<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:46771<p>The output format from "git-diff-index", "git-diff-tree",
772"git-diff-files" and "git diff --raw" are very similar.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23773<p>These commands all compare two sets of things; what is
774compared differs:</p>
775<dl>
776<dt>
777git-diff-index &lt;tree-ish&gt;
778</dt>
779<dd>
780<p>
781 compares the &lt;tree-ish&gt; and the files on the filesystem.
782</p>
783</dd>
784<dt>
785git-diff-index --cached &lt;tree-ish&gt;
786</dt>
787<dd>
788<p>
789 compares the &lt;tree-ish&gt; and the index.
790</p>
791</dd>
792<dt>
793git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
794</dt>
795<dd>
796<p>
797 compares the trees named by the two arguments.
798</p>
799</dd>
800<dt>
801git-diff-files [&lt;pattern&gt;&#8230;]
802</dt>
803<dd>
804<p>
805 compares the index and the files on the filesystem.
806</p>
807</dd>
808</dl>
809<p>An output line is formatted this way:</p>
810<div class="listingblock">
811<div class="content">
812<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
813copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
814rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
815create :000000 100644 0000000... 1234567... A file4
816delete :100644 000000 1234567... 0000000... D file5
817unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
818</div></div>
819<p>That is, from the left to the right:</p>
820<ol>
821<li>
822<p>
823a colon.
824</p>
825</li>
826<li>
827<p>
828mode for "src"; 000000 if creation or unmerged.
829</p>
830</li>
831<li>
832<p>
833a space.
834</p>
835</li>
836<li>
837<p>
838mode for "dst"; 000000 if deletion or unmerged.
839</p>
840</li>
841<li>
842<p>
843a space.
844</p>
845</li>
846<li>
847<p>
848sha1 for "src"; 0{40} if creation or unmerged.
849</p>
850</li>
851<li>
852<p>
853a space.
854</p>
855</li>
856<li>
857<p>
858sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
859</p>
860</li>
861<li>
862<p>
863a space.
864</p>
865</li>
866<li>
867<p>
868status, followed by optional "score" number.
869</p>
870</li>
871<li>
872<p>
873a tab or a NUL when <em>-z</em> option is used.
874</p>
875</li>
876<li>
877<p>
878path for "src"
879</p>
880</li>
881<li>
882<p>
883a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
884</p>
885</li>
886<li>
887<p>
888path for "dst"; only exists for C or R.
889</p>
890</li>
891<li>
892<p>
893an LF or a NUL when <em>-z</em> option is used, to terminate the record.
894</p>
895</li>
896</ol>
897<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
898and it is out of sync with the index.</p>
899<p>Example:</p>
900<div class="listingblock">
901<div class="content">
902<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
903</div></div>
904<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
905in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
906respectively.</p>
907</div>
Junio C Hamano67fad6d2007-05-06 08:53:12908<h2>diff format for merges</h2>
909<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:46910<p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
911can take <em>-c</em> or <em>--cc</em> option
Junio C Hamano67fad6d2007-05-06 08:53:12912to generate diff output also for merge commits. The output differs
913from the format described above in the following way:</p>
914<ol>
915<li>
916<p>
917there is a colon for each parent
918</p>
919</li>
920<li>
921<p>
922there are more "src" modes and "src" sha1
923</p>
924</li>
925<li>
926<p>
927status is concatenated status characters for each parent
928</p>
929</li>
930<li>
931<p>
932no optional "score" number
933</p>
934</li>
935<li>
936<p>
937single path, only for "dst"
938</p>
939</li>
940</ol>
941<p>Example:</p>
942<div class="listingblock">
943<div class="content">
944<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
945</div></div>
946<p>Note that <em>combined diff</em> lists only files which were modified from
947all parents.</p>
948</div>
Junio C Hamano1a4e8412005-12-27 08:17:23949<h2>Generating patches with -p</h2>
950<div class="sectionbody">
951<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:49952with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
953"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:46954do not produce the output described above; instead they produce a
955patch file. You can customize the creation of such patches via the
956GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p>
Junio C Hamano1c437122006-11-28 02:22:25957<p>What the -p option produces is slightly different from the traditional
958diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23959<ol>
960<li>
961<p>
Junio C Hamano235a91e2006-01-07 01:13:58962It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:23963 this:
964</p>
965<div class="literalblock">
966<div class="content">
967<pre><tt>diff --git a/file1 b/file2</tt></pre>
968</div></div>
969<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
970involved. Especially, even for a creation or a deletion,
971<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
972<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
973name of the source file of the rename/copy and the name of
974the file that rename/copy produces, respectively.</p>
975</li>
976<li>
977<p>
978It is followed by one or more extended header lines:
979</p>
980<div class="literalblock">
981<div class="content">
982<pre><tt>old mode &lt;mode&gt;
983new mode &lt;mode&gt;
984deleted file mode &lt;mode&gt;
985new file mode &lt;mode&gt;
986copy from &lt;path&gt;
987copy to &lt;path&gt;
988rename from &lt;path&gt;
989rename to &lt;path&gt;
990similarity index &lt;number&gt;
991dissimilarity index &lt;number&gt;
992index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
993</div></div>
994</li>
995<li>
996<p>
Junio C Hamanoa053d542006-10-27 09:29:13997TAB, LF, double quote and backslash characters in pathnames
998 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
999 If there is need for such substitution then the whole
1000 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231001</p>
1002</li>
1003</ol>
Junio C Hamanod526ba92007-07-02 00:17:421004<p>The similarity index is the percentage of unchanged lines, and
1005the dissimilarity index is the percentage of changed lines. It
1006is a rounded down integer, followed by a percent sign. The
1007similarity index value of 100% is thus reserved for two equal
1008files, while 100% dissimilarity means that no line from the old
1009file made it into the new one.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231010</div>
Junio C Hamanofb56a962006-01-28 10:38:191011<h2>combined diff format</h2>
1012<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461013<p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
Junio C Hamano00b8b632007-12-07 09:50:491014<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1015with "git log -p", this is the default format.
1016A <em>combined diff</em> format looks like this:</p>
Junio C Hamanofb56a962006-01-28 10:38:191017<div class="listingblock">
1018<div class="content">
1019<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291020index fabadb8,cc95eb0..4866510
1021--- a/describe.c
1022+++ b/describe.c
1023@@@ -98,20 -98,12 +98,20 @@@
1024 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191025 }
1026
1027- static void describe(char *arg)
1028 -static void describe(struct commit *cmit, int last_one)
1029++static void describe(char *arg, int last_one)
1030 {
Junio C Hamano29f14312006-10-26 08:47:291031 + unsigned char sha1[20];
1032 + struct commit *cmit;
1033 struct commit_list *list;
1034 static int initialized = 0;
1035 struct commit_name *n;
1036
1037 + if (get_sha1(arg, sha1) &lt; 0)
1038 + usage(describe_usage);
1039 + cmit = lookup_commit_reference(sha1);
1040 + if (!cmit)
1041 + usage(describe_usage);
1042 +
1043 if (!initialized) {
1044 initialized = 1;
1045 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191046</div></div>
Junio C Hamano29f14312006-10-26 08:47:291047<ol>
1048<li>
1049<p>
1050It is preceded with a "git diff" header, that looks like
1051 this (when <em>-c</em> option is used):
1052</p>
1053<div class="literalblock">
1054<div class="content">
1055<pre><tt>diff --combined file</tt></pre>
1056</div></div>
1057<p>or like this (when <em>--cc</em> option is used):</p>
1058<div class="literalblock">
1059<div class="content">
1060<pre><tt>diff --c file</tt></pre>
1061</div></div>
1062</li>
1063<li>
1064<p>
1065It is followed by one or more extended header lines
1066 (this example shows a merge with two parents):
1067</p>
1068<div class="literalblock">
1069<div class="content">
1070<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1071mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1072new file mode &lt;mode&gt;
1073deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1074</div></div>
1075<p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
Junio C Hamanoee1e4282007-02-04 08:32:041076the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291077information about detected contents movement (renames and
1078copying detection) are designed to work with diff of two
1079&lt;tree-ish&gt; and are not used by combined diff format.</p>
1080</li>
1081<li>
1082<p>
1083It is followed by two-line from-file/to-file header
1084</p>
1085<div class="literalblock">
1086<div class="content">
1087<pre><tt>--- a/file
1088+++ b/file</tt></pre>
1089</div></div>
1090<p>Similar to two-line header for traditional <em>unified</em> diff
1091format, <tt>/dev/null</tt> is used to signal created or deleted
1092files.</p>
1093</li>
1094<li>
1095<p>
1096Chunk header format is modified to prevent people from
1097 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1098 was created for review of merge commit changes, and was not
1099 meant for apply. The change is similar to the change in the
1100 extended <em>index</em> header:
1101</p>
1102<div class="literalblock">
1103<div class="content">
1104<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1105</div></div>
1106<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1107header for combined diff format.</p>
1108</li>
1109</ol>
Junio C Hamanofb56a962006-01-28 10:38:191110<p>Unlike the traditional <em>unified</em> diff format, which shows two
1111files A and B with a single column that has <tt>-</tt> (minus &#8212;
1112appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291113added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191114compares two or more files file1, file2,&#8230; with one file X, and
1115shows how X differs from each of fileN. One column for each of
1116fileN is prepended to the output line to note how X's line is
1117different from it.</p>
1118<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291119fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191120in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291121and fileN does not have that line (in other words, the line was
1122added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191123<p>In the above example output, the function signature was changed
1124from both files (hence two <tt>-</tt> removals from both file1 and
1125file2, plus <tt>++</tt> to mean one line that was added does not appear
1126in either file1 nor file2). Also two other lines are the same
1127from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1128<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1129merge commit with the merge result (i.e. file1..fileN are the
1130parents). When shown by <tt>git diff-files -c</tt>, it compares the
1131two unresolved merge parents with the working tree file
1132(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1133"their version").</p>
1134</div>
Junio C Hamano3a702342007-12-12 21:34:021135<h2>other diff formats</h2>
1136<div class="sectionbody">
1137<p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1138copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1139output. These options can be combined with other options, such as
1140<tt>-p</tt>, and are meant for human consumption.</p>
1141<p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1142formats the pathnames compactly by combining common prefix and suffix of
1143the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1144<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p>
1145<div class="listingblock">
1146<div class="content">
1147<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1148</div></div>
1149<p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1150for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1151like this:</p>
1152<div class="listingblock">
1153<div class="content">
1154<pre><tt>1 2 README
11553 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1156</div></div>
1157<p>That is, from left to right:</p>
1158<ol>
1159<li>
1160<p>
1161the number of added lines;
1162</p>
1163</li>
1164<li>
1165<p>
1166a tab;
1167</p>
1168</li>
1169<li>
1170<p>
1171the number of deleted lines;
1172</p>
1173</li>
1174<li>
1175<p>
1176a tab;
1177</p>
1178</li>
1179<li>
1180<p>
1181pathname (possibly with rename/copy information);
1182</p>
1183</li>
1184<li>
1185<p>
1186a newline.
1187</p>
1188</li>
1189</ol>
1190<p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p>
1191<div class="listingblock">
1192<div class="content">
1193<pre><tt>1 2 README NUL
11943 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1195</div></div>
1196<p>That is:</p>
1197<ol>
1198<li>
1199<p>
1200the number of added lines;
1201</p>
1202</li>
1203<li>
1204<p>
1205a tab;
1206</p>
1207</li>
1208<li>
1209<p>
1210the number of deleted lines;
1211</p>
1212</li>
1213<li>
1214<p>
1215a tab;
1216</p>
1217</li>
1218<li>
1219<p>
1220a NUL (only exists if renamed/copied);
1221</p>
1222</li>
1223<li>
1224<p>
1225pathname in preimage;
1226</p>
1227</li>
1228<li>
1229<p>
1230a NUL (only exists if renamed/copied);
1231</p>
1232</li>
1233<li>
1234<p>
1235pathname in postimage (only exists if renamed/copied);
1236</p>
1237</li>
1238<li>
1239<p>
1240a NUL.
1241</p>
1242</li>
1243</ol>
1244<p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1245scripts that read the output to tell if the current record being read is
1246a single-path record or a rename/copy record without reading ahead.
1247After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1248the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p>
1249</div>
Junio C Hamano1a4e8412005-12-27 08:17:231250<h2>Author</h2>
1251<div class="sectionbody">
1252<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1253</div>
1254<h2>Documentation</h2>
1255<div class="sectionbody">
1256<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1257</div>
1258<h2>GIT</h2>
1259<div class="sectionbody">
1260<p>Part of the <a href="git.html">git(7)</a> suite</p>
1261</div>
1262<div id="footer">
1263<div id="footer-text">
Junio C Hamano35738e82008-01-07 07:55:461264Last updated 07-Jan-2008 07:50:13 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231265</div>
1266</div>
1267</body>
1268</html>