blob: 78b496d7ba1e57d4660d0dea0d627d3dd0943ba1 [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 Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
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
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1a4e8412005-12-27 08:17:2326
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, 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;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2384}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#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;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.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;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1a4e8412005-12-27 08:17:23155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
172div.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;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1a4e8412005-12-27 08:17:23236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#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;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1a4e8412005-12-27 08:17:23275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-diff-index(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-diff-index(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-diff-index -
317 Compares content and mode of blobs between the index and repository
318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31323<div class="para"><p><em>git diff-index</em> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23324</div>
Junio C Hamanoba4b9282008-07-06 05:20:31325<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23326<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31327<div class="para"><p>Compares the content and mode of the blobs found via a tree
Junio C Hamano1a4e8412005-12-27 08:17:23328object with the content of the current index and, optionally
329ignoring the stat state of the file on disk. When paths are
330specified, compares only those named paths. Otherwise all
Junio C Hamanoba4b9282008-07-06 05:20:31331entries in the index are compared.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23332</div>
Junio C Hamanoba4b9282008-07-06 05:20:31333<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23334<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31335<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23336<dt>
337-p
338</dt>
Junio C Hamanobbbb8652008-12-29 10:34:22339<dt>
340-u
341</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23342<dd>
343<p>
Junio C Hamanoff979792007-11-16 10:11:30344 Generate patch (see section on generating patches).
345
Junio C Hamano1a4e8412005-12-27 08:17:23346</p>
347</dd>
348<dt>
Junio C Hamano69361562007-07-26 02:14:34349-U&lt;n&gt;
350</dt>
Junio C Hamano69361562007-07-26 02:14:34351<dt>
352--unified=&lt;n&gt;
353</dt>
354<dd>
355<p>
356 Generate diffs with &lt;n&gt; lines of context instead of
Junio C Hamano3b70d3c2009-11-21 17:37:37357 the usual three.
358 Implies <tt>-p</tt>.
Junio C Hamano69361562007-07-26 02:14:34359</p>
360</dd>
361<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34362--raw
363</dt>
364<dd>
365<p>
366 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30367 This is the default.
Junio C Hamano9ae1a062006-07-10 08:12:34368</p>
369</dd>
370<dt>
Junio C Hamano54559c82006-04-13 07:45:12371--patch-with-raw
372</dt>
373<dd>
374<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37375 Synonym for <tt>-p --raw</tt>.
Junio C Hamano54559c82006-04-13 07:45:12376</p>
377</dd>
Junio C Hamano20d47e32009-01-26 06:36:02378<dt>
379--patience
380</dt>
381<dd>
382<p>
383 Generate a diff using the "patience diff" algorithm.
384</p>
385</dd>
Junio C Hamano54559c82006-04-13 07:45:12386<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29387--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42388</dt>
389<dd>
390<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29391 Generate a diffstat. You can override the default
Junio C Hamano3b70d3c2009-11-21 17:37:37392 output width for 80-column terminal by <tt>--stat=width</tt>.
Junio C Hamano4a9a76a2006-10-01 05:40:29393 The width of the filename part can be controlled by
394 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42395</p>
396</dd>
397<dt>
Junio C Hamanofbe00522006-10-19 05:58:48398--numstat
399</dt>
400<dd>
401<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37402 Similar to <tt>--stat</tt>, but shows number of added and
Junio C Hamanofbe00522006-10-19 05:58:48403 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43404 abbreviation, to make it more machine friendly. For
405 binary files, outputs two <tt>-</tt> instead of saying
406 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48407</p>
408</dd>
409<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04410--shortstat
411</dt>
412<dd>
413<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37414 Output only the last line of the <tt>--stat</tt> format containing total
Junio C Hamano7d23f5e2006-12-16 07:44:04415 number of modified files, as well as number of added and deleted
416 lines.
417</p>
418</dd>
419<dt>
Junio C Hamano6a45be92008-04-22 08:19:03420--dirstat[=limit]
421</dt>
422<dd>
423<p>
Junio C Hamanoa2f46622008-09-03 05:20:31424 Output the distribution of relative amount of changes (number of lines added or
425 removed) for each sub-directory. Directories with changes below
426 a cut-off percent (3% by default) are not shown. The cut-off percent
Junio C Hamano3b70d3c2009-11-21 17:37:37427 can be set with <tt>--dirstat=limit</tt>. Changes in a child directory is not
428 counted for the parent directory, unless <tt>--cumulative</tt> is used.
Junio C Hamano6a45be92008-04-22 08:19:03429</p>
430</dd>
431<dt>
Junio C Hamanoa476efa2008-10-10 15:31:42432--dirstat-by-file[=limit]
433</dt>
434<dd>
435<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37436 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
Junio C Hamanoa476efa2008-10-10 15:31:42437</p>
438</dd>
439<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11440--summary
441</dt>
442<dd>
443<p>
444 Output a condensed summary of extended header information
445 such as creations, renames and mode changes.
446</p>
447</dd>
448<dt>
Junio C Hamanod1308c92006-04-16 11:01:09449--patch-with-stat
450</dt>
451<dd>
452<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37453 Synonym for <tt>-p --stat</tt>.
Junio C Hamanod1308c92006-04-16 11:01:09454</p>
455</dd>
456<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23457-z
458</dt>
459<dd>
460<p>
Junio C Hamano5706e0b2009-11-24 10:54:16461 When <tt>--raw</tt> or <tt>--numstat</tt> has been given, do not munge
462 pathnames and use NULs as output field terminators.
Junio C Hamano1a4e8412005-12-27 08:17:23463</p>
Junio C Hamano5706e0b2009-11-24 10:54:16464<div class="para"><p>Without this option, each pathname output will have TAB, LF, double quotes,
465and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
466respectively, and the pathname will be enclosed in double quotes if
467any of those replacements occurred.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23468</dd>
469<dt>
470--name-only
471</dt>
472<dd>
473<p>
474 Show only names of changed files.
475</p>
476</dd>
477<dt>
478--name-status
479</dt>
480<dd>
481<p>
Junio C Hamanoa9aee782008-04-23 16:09:20482 Show only names and status of changed files. See the description
483 of the <tt>--diff-filter</tt> option on what the status letters mean.
Junio C Hamano1a4e8412005-12-27 08:17:23484</p>
485</dd>
486<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55487--submodule[=&lt;format&gt;]
488</dt>
489<dd>
490<p>
491 Chose the output format for submodule differences. &lt;format&gt; can be one of
492 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
493 is used when this option is not given. <em>log</em> is the default value for this
494 option and lists the commits in that commit range like the <em>summary</em>
495 option of <a href="git-submodule.html">git-submodule(1)</a> does.
496</p>
497</dd>
498<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34499--color
500</dt>
501<dd>
502<p>
503 Show colored diff.
504</p>
505</dd>
506<dt>
507--no-color
508</dt>
509<dd>
510<p>
511 Turn off colored diff, even when the configuration file
512 gives the default to color output.
513</p>
514</dd>
515<dt>
Junio C Hamano20d47e32009-01-26 06:36:02516--color-words[=&lt;regex&gt;]
Junio C Hamano85e45fa2006-08-13 07:47:41517</dt>
518<dd>
519<p>
Junio C Hamano20d47e32009-01-26 06:36:02520 Show colored word diff, i.e., color words which have changed.
521 By default, words are separated by whitespace.
Junio C Hamano85e45fa2006-08-13 07:47:41522</p>
Junio C Hamano20d47e32009-01-26 06:36:02523<div class="para"><p>When a &lt;regex&gt; is specified, every non-overlapping match of the
524&lt;regex&gt; is considered a word. Anything between these matches is
525considered whitespace and ignored(!) for the purposes of finding
526differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
527expression to make sure that it matches all non-whitespace characters.
528A match that contains a newline is silently truncated(!) at the
529newline.</p></div>
530<div class="para"><p>The regex can also be set via a diff driver or configuration option, see
531<a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
532overrides any diff driver or configuration setting. Diff drivers
533override configuration settings.</p></div>
Junio C Hamano85e45fa2006-08-13 07:47:41534</dd>
535<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34536--no-renames
537</dt>
538<dd>
539<p>
540 Turn off rename detection, even when the configuration
541 file gives the default to do so.
542</p>
543</dd>
544<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21545--check
546</dt>
547<dd>
548<p>
549 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54550 or an indent that uses a space before a tab. Exits with
551 non-zero status if problems are found. Not compatible with
552 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21553</p>
554</dd>
555<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23556--full-index
557</dt>
558<dd>
559<p>
Junio C Hamano5cf43ca2008-08-20 09:14:14560 Instead of the first handful of characters, show the full
561 pre- and post-image blob object names on the "index"
562 line when generating patch format output.
Junio C Hamano1a4e8412005-12-27 08:17:23563</p>
564</dd>
565<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34566--binary
567</dt>
568<dd>
569<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37570 In addition to <tt>--full-index</tt>, output a binary diff that
571 can be applied with <tt>git-apply</tt>.
Junio C Hamano9ae1a062006-07-10 08:12:34572</p>
573</dd>
574<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23575--abbrev[=&lt;n&gt;]
576</dt>
577<dd>
578<p>
579 Instead of showing the full 40-byte hexadecimal object
580 name in diff-raw format output and diff-tree header
Junio C Hamano6efe3022009-01-13 16:47:56581 lines, show only a partial prefix. This is
Junio C Hamano3b70d3c2009-11-21 17:37:37582 independent of the <tt>--full-index</tt> option above, which controls
Junio C Hamano1a4e8412005-12-27 08:17:23583 the diff-patch output format. Non default number of
Junio C Hamano3b70d3c2009-11-21 17:37:37584 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23585</p>
586</dd>
587<dt>
588-B
589</dt>
590<dd>
591<p>
592 Break complete rewrite changes into pairs of delete and create.
593</p>
594</dd>
595<dt>
596-M
597</dt>
598<dd>
599<p>
600 Detect renames.
601</p>
602</dd>
603<dt>
604-C
605</dt>
606<dd>
607<p>
Junio C Hamano16f98872007-06-12 16:09:14608 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23609</p>
610</dd>
611<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01612--diff-filter=[ACDMRTUXB*]
613</dt>
614<dd>
615<p>
616 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
617 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
Junio C Hamanoa2deec52008-10-18 18:58:09618 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
619 are Unmerged (<tt>U</tt>), are
Junio C Hamano6ec31b92006-02-10 05:52:01620 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
621 Any combination of the filter characters may be used.
622 When <tt>*</tt> (All-or-none) is added to the combination, all
623 paths are selected if there is any file that matches
624 other criteria in the comparison; if there is no file
625 that matches other criteria, nothing is selected.
626</p>
627</dd>
628<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23629--find-copies-harder
630</dt>
631<dd>
632<p>
Junio C Hamano16f98872007-06-12 16:09:14633 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23634 if the original file of the copy was modified in the same
635 changeset. This flag makes the command
636 inspect unmodified files as candidates for the source of
637 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14638 projects, so use it with caution. Giving more than one
639 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23640</p>
641</dd>
642<dt>
643-l&lt;num&gt;
644</dt>
645<dd>
646<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37647 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
Junio C Hamano1a4e8412005-12-27 08:17:23648 is the number of potential rename/copy targets. This
649 option prevents rename/copy detection from running if
650 the number of rename/copy targets exceeds the specified
651 number.
652</p>
653</dd>
654<dt>
655-S&lt;string&gt;
656</dt>
657<dd>
658<p>
Junio C Hamano5217a272009-03-21 00:39:33659 Look for differences that introduce or remove an instance of
660 &lt;string&gt;. Note that this is different than the string simply
661 appearing in diff output; see the <em>pickaxe</em> entry in
662 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
Junio C Hamano1a4e8412005-12-27 08:17:23663</p>
664</dd>
665<dt>
666--pickaxe-all
667</dt>
668<dd>
669<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37670 When <tt>-S</tt> finds a change, show all the changes in that
Junio C Hamano1a4e8412005-12-27 08:17:23671 changeset, not just the files that contain the change
672 in &lt;string&gt;.
673</p>
674</dd>
675<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28676--pickaxe-regex
677</dt>
678<dd>
679<p>
680 Make the &lt;string&gt; not a plain string but an extended POSIX
681 regex to match.
682</p>
683</dd>
684<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23685-O&lt;orderfile&gt;
686</dt>
687<dd>
688<p>
689 Output the patch in the order specified in the
690 &lt;orderfile&gt;, which has one shell glob pattern per line.
691</p>
692</dd>
693<dt>
694-R
695</dt>
696<dd>
697<p>
698 Swap two inputs; that is, show differences from index or
699 on-disk file to tree contents.
700</p>
701</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14702<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44703--relative[=&lt;path&gt;]
704</dt>
705<dd>
706<p>
707 When run from a subdirectory of the project, it can be
708 told to exclude changes outside the directory and show
709 pathnames relative to it with this option. When you are
710 not in a subdirectory (e.g. in a bare repository), you
711 can name which subdirectory to make the output relative
712 to by giving a &lt;path&gt; as an argument.
713</p>
714</dd>
715<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22716-a
717</dt>
718<dt>
Junio C Hamanoc26f5482006-07-09 09:38:14719--text
720</dt>
721<dd>
722<p>
723 Treat all files as text.
724</p>
725</dd>
726<dt>
Junio C Hamanofd468962007-02-14 23:45:04727--ignore-space-at-eol
728</dt>
729<dd>
730<p>
Junio C Hamano3a702342007-12-12 21:34:02731 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04732</p>
733</dd>
734<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22735-b
736</dt>
737<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07738--ignore-space-change
739</dt>
740<dd>
741<p>
Junio C Hamano3a702342007-12-12 21:34:02742 Ignore changes in amount of whitespace. This ignores whitespace
743 at line end, and considers all other sequences of one or
744 more whitespace characters to be equivalent.
Junio C Hamanod9c2d2f2006-12-06 08:59:07745</p>
746</dd>
747<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22748-w
Junio C Hamanod9c2d2f2006-12-06 08:59:07749</dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07750<dt>
751--ignore-all-space
752</dt>
753<dd>
754<p>
Junio C Hamano3a702342007-12-12 21:34:02755 Ignore whitespace when comparing lines. This ignores
756 differences even if one line has whitespace where the other
Junio C Hamanod9c2d2f2006-12-06 08:59:07757 line has none.
758</p>
759</dd>
760<dt>
Junio C Hamano1d40ee82009-01-07 10:14:16761--inter-hunk-context=&lt;lines&gt;
762</dt>
763<dd>
764<p>
765 Show the context between diff hunks, up to the specified number
766 of lines, thereby fusing hunks that are close to each other.
767</p>
768</dd>
769<dt>
Junio C Hamano48fd2f62007-03-19 02:02:30770--exit-code
771</dt>
772<dd>
773<p>
774 Make the program exit with codes similar to diff(1).
775 That is, it exits with 1 if there were differences and
776 0 means no differences.
777</p>
778</dd>
Junio C Hamano35e57552007-03-25 07:54:35779<dt>
780--quiet
781</dt>
782<dd>
783<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37784 Disable all output of the program. Implies <tt>--exit-code</tt>.
Junio C Hamano35e57552007-03-25 07:54:35785</p>
786</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40787<dt>
788--ext-diff
789</dt>
790<dd>
791<p>
792 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53793 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
794 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40795</p>
796</dd>
797<dt>
798--no-ext-diff
799</dt>
800<dd>
801<p>
802 Disallow external diff drivers.
803</p>
804</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33805<dt>
Junio C Hamanodfccbb02008-05-26 01:16:14806--ignore-submodules
807</dt>
808<dd>
809<p>
810 Ignore changes to submodules in the diff generation.
811</p>
812</dd>
813<dt>
Junio C Hamanoe27cbd22007-12-21 17:57:33814--src-prefix=&lt;prefix&gt;
815</dt>
816<dd>
817<p>
818 Show the given source prefix instead of "a/".
819</p>
820</dd>
821<dt>
822--dst-prefix=&lt;prefix&gt;
823</dt>
824<dd>
825<p>
826 Show the given destination prefix instead of "b/".
827</p>
828</dd>
829<dt>
830--no-prefix
831</dt>
832<dd>
833<p>
834 Do not show any source or destination prefix.
835</p>
836</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31837</dl></div>
838<div class="para"><p>For more detailed explanation on these common options, see also
839<a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
840<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23841<dt>
842&lt;tree-ish&gt;
843</dt>
844<dd>
845<p>
846 The id of a tree object to diff against.
847</p>
848</dd>
849<dt>
850--cached
851</dt>
852<dd>
853<p>
854 do not consider the on-disk file at all
855</p>
856</dd>
857<dt>
858-m
859</dt>
860<dd>
861<p>
862 By default, files recorded in the index but not checked
863 out are reported as deleted. This flag makes
Junio C Hamano1aa40d22010-01-21 17:46:43864 <em>git diff-index</em> say that all non-checked-out files are up
Junio C Hamano1a4e8412005-12-27 08:17:23865 to date.
866</p>
867</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31868</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23869</div>
Junio C Hamano543f8d62009-07-29 08:35:21870<h2 id="_raw_output_format">Raw output format</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23871<div class="sectionbody">
Junio C Hamano543f8d62009-07-29 08:35:21872<div class="para"><p>The raw output format from "git-diff-index", "git-diff-tree",
Junio C Hamanoba4b9282008-07-06 05:20:31873"git-diff-files" and "git diff --raw" are very similar.</p></div>
874<div class="para"><p>These commands all compare two sets of things; what is
875compared differs:</p></div>
876<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23877<dt>
878git-diff-index &lt;tree-ish&gt;
879</dt>
880<dd>
881<p>
882 compares the &lt;tree-ish&gt; and the files on the filesystem.
883</p>
884</dd>
885<dt>
886git-diff-index --cached &lt;tree-ish&gt;
887</dt>
888<dd>
889<p>
890 compares the &lt;tree-ish&gt; and the index.
891</p>
892</dd>
893<dt>
894git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
895</dt>
896<dd>
897<p>
898 compares the trees named by the two arguments.
899</p>
900</dd>
901<dt>
902git-diff-files [&lt;pattern&gt;&#8230;]
903</dt>
904<dd>
905<p>
906 compares the index and the files on the filesystem.
907</p>
908</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31909</dl></div>
Junio C Hamano543f8d62009-07-29 08:35:21910<div class="para"><p>The "git-diff-tree" command begins its ouput by printing the hash of
911what is being compared. After that, all the commands print one output
912line per changed file.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31913<div class="para"><p>An output line is formatted this way:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23914<div class="listingblock">
915<div class="content">
916<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
917copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
918rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
919create :000000 100644 0000000... 1234567... A file4
920delete :100644 000000 1234567... 0000000... D file5
921unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
922</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31923<div class="para"><p>That is, from the left to the right:</p></div>
924<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:23925<li>
926<p>
927a colon.
928</p>
929</li>
930<li>
931<p>
932mode for "src"; 000000 if creation or unmerged.
933</p>
934</li>
935<li>
936<p>
937a space.
938</p>
939</li>
940<li>
941<p>
942mode for "dst"; 000000 if deletion or unmerged.
943</p>
944</li>
945<li>
946<p>
947a space.
948</p>
949</li>
950<li>
951<p>
952sha1 for "src"; 0{40} if creation or unmerged.
953</p>
954</li>
955<li>
956<p>
957a space.
958</p>
959</li>
960<li>
961<p>
962sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
963</p>
964</li>
965<li>
966<p>
967a space.
968</p>
969</li>
970<li>
971<p>
972status, followed by optional "score" number.
973</p>
974</li>
975<li>
976<p>
977a tab or a NUL when <em>-z</em> option is used.
978</p>
979</li>
980<li>
981<p>
982path for "src"
983</p>
984</li>
985<li>
986<p>
987a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
988</p>
989</li>
990<li>
991<p>
992path for "dst"; only exists for C or R.
993</p>
994</li>
995<li>
996<p>
997an LF or a NUL when <em>-z</em> option is used, to terminate the record.
998</p>
999</li>
Junio C Hamanoba4b9282008-07-06 05:20:311000</ol></div>
Junio C Hamanoaa17c7c2008-11-03 04:36:581001<div class="para"><p>Possible status letters are:</p></div>
1002<div class="ilist"><ul>
1003<li>
1004<p>
1005A: addition of a file
1006</p>
1007</li>
1008<li>
1009<p>
1010C: copy of a file into a new one
1011</p>
1012</li>
1013<li>
1014<p>
1015D: deletion of a file
1016</p>
1017</li>
1018<li>
1019<p>
1020M: modification of the contents or mode of a file
1021</p>
1022</li>
1023<li>
1024<p>
1025R: renaming of a file
1026</p>
1027</li>
1028<li>
1029<p>
1030T: change in the type of the file
1031</p>
1032</li>
1033<li>
1034<p>
1035U: file is unmerged (you must complete the merge before it can
1036be committed)
1037</p>
1038</li>
1039<li>
1040<p>
1041X: "unknown" change type (most probably a bug, please report it)
1042</p>
1043</li>
1044</ul></div>
Junio C Hamano54bf1e22008-12-20 06:30:111045<div class="para"><p>Status letters C and R are always followed by a score (denoting the
Junio C Hamanoaa17c7c2008-11-03 04:36:581046percentage of similarity between the source and target of the move or
1047copy), and are the only ones to be so.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311048<div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1049and it is out of sync with the index.</p></div>
1050<div class="para"><p>Example:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231051<div class="listingblock">
1052<div class="content">
1053<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1054</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311055<div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
Junio C Hamano1a4e8412005-12-27 08:17:231056in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
Junio C Hamanoba4b9282008-07-06 05:20:311057respectively.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231058</div>
Junio C Hamanoba4b9282008-07-06 05:20:311059<h2 id="_diff_format_for_merges">diff format for merges</h2>
Junio C Hamano67fad6d2007-05-06 08:53:121060<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311061<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
Junio C Hamano7ae0ab22007-11-03 02:46:461062can take <em>-c</em> or <em>--cc</em> option
Junio C Hamano67fad6d2007-05-06 08:53:121063to generate diff output also for merge commits. The output differs
Junio C Hamanoba4b9282008-07-06 05:20:311064from the format described above in the following way:</p></div>
1065<div class="olist"><ol>
Junio C Hamano67fad6d2007-05-06 08:53:121066<li>
1067<p>
1068there is a colon for each parent
1069</p>
1070</li>
1071<li>
1072<p>
1073there are more "src" modes and "src" sha1
1074</p>
1075</li>
1076<li>
1077<p>
1078status is concatenated status characters for each parent
1079</p>
1080</li>
1081<li>
1082<p>
1083no optional "score" number
1084</p>
1085</li>
1086<li>
1087<p>
1088single path, only for "dst"
1089</p>
1090</li>
Junio C Hamanoba4b9282008-07-06 05:20:311091</ol></div>
1092<div class="para"><p>Example:</p></div>
Junio C Hamano67fad6d2007-05-06 08:53:121093<div class="listingblock">
1094<div class="content">
1095<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1096</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311097<div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1098all parents.</p></div>
Junio C Hamano67fad6d2007-05-06 08:53:121099</div>
Junio C Hamanoba4b9282008-07-06 05:20:311100<h2 id="_generating_patches_with_p">Generating patches with -p</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231101<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311102<div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491103with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1104"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461105do not produce the output described above; instead they produce a
1106patch file. You can customize the creation of such patches via the
Junio C Hamanoba4b9282008-07-06 05:20:311107GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1108<div class="para"><p>What the -p option produces is slightly different from the traditional
1109diff format.</p></div>
1110<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:231111<li>
1112<p>
Junio C Hamano235a91e2006-01-07 01:13:581113It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231114 this:
1115</p>
1116<div class="literalblock">
1117<div class="content">
1118<pre><tt>diff --git a/file1 b/file2</tt></pre>
1119</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311120<div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
Junio C Hamano1a4e8412005-12-27 08:17:231121involved. Especially, even for a creation or a deletion,
Junio C Hamanoe1b26832009-11-15 10:02:561122<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311123<div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
Junio C Hamano1a4e8412005-12-27 08:17:231124name of the source file of the rename/copy and the name of
Junio C Hamanoba4b9282008-07-06 05:20:311125the file that rename/copy produces, respectively.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231126</li>
1127<li>
1128<p>
1129It is followed by one or more extended header lines:
1130</p>
1131<div class="literalblock">
1132<div class="content">
1133<pre><tt>old mode &lt;mode&gt;
1134new mode &lt;mode&gt;
1135deleted file mode &lt;mode&gt;
1136new file mode &lt;mode&gt;
1137copy from &lt;path&gt;
1138copy to &lt;path&gt;
1139rename from &lt;path&gt;
1140rename to &lt;path&gt;
1141similarity index &lt;number&gt;
1142dissimilarity index &lt;number&gt;
1143index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1144</div></div>
1145</li>
1146<li>
1147<p>
Junio C Hamanoa053d542006-10-27 09:29:131148TAB, LF, double quote and backslash characters in pathnames
1149 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1150 If there is need for such substitution then the whole
1151 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231152</p>
1153</li>
Junio C Hamanoba4b9282008-07-06 05:20:311154</ol></div>
1155<div class="para"><p>The similarity index is the percentage of unchanged lines, and
Junio C Hamanod526ba92007-07-02 00:17:421156the dissimilarity index is the percentage of changed lines. It
1157is a rounded down integer, followed by a percent sign. The
1158similarity index value of 100% is thus reserved for two equal
1159files, while 100% dissimilarity means that no line from the old
Junio C Hamanoba4b9282008-07-06 05:20:311160file made it into the new one.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231161</div>
Junio C Hamanoba4b9282008-07-06 05:20:311162<h2 id="_combined_diff_format">combined diff format</h2>
Junio C Hamanofb56a962006-01-28 10:38:191163<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311164<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
Junio C Hamano00b8b632007-12-07 09:50:491165<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1166with "git log -p", this is the default format.
Junio C Hamanoba4b9282008-07-06 05:20:311167A <em>combined diff</em> format looks like this:</p></div>
Junio C Hamanofb56a962006-01-28 10:38:191168<div class="listingblock">
1169<div class="content">
1170<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291171index fabadb8,cc95eb0..4866510
1172--- a/describe.c
1173+++ b/describe.c
1174@@@ -98,20 -98,12 +98,20 @@@
1175 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191176 }
1177
1178- static void describe(char *arg)
1179 -static void describe(struct commit *cmit, int last_one)
1180++static void describe(char *arg, int last_one)
1181 {
Junio C Hamano29f14312006-10-26 08:47:291182 + unsigned char sha1[20];
1183 + struct commit *cmit;
1184 struct commit_list *list;
1185 static int initialized = 0;
1186 struct commit_name *n;
1187
1188 + if (get_sha1(arg, sha1) &lt; 0)
1189 + usage(describe_usage);
1190 + cmit = lookup_commit_reference(sha1);
1191 + if (!cmit)
1192 + usage(describe_usage);
1193 +
1194 if (!initialized) {
1195 initialized = 1;
1196 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191197</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311198<div class="olist"><ol>
Junio C Hamano29f14312006-10-26 08:47:291199<li>
1200<p>
1201It is preceded with a "git diff" header, that looks like
1202 this (when <em>-c</em> option is used):
1203</p>
1204<div class="literalblock">
1205<div class="content">
1206<pre><tt>diff --combined file</tt></pre>
1207</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311208<div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
Junio C Hamano29f14312006-10-26 08:47:291209<div class="literalblock">
1210<div class="content">
Junio C Hamano0868a302008-07-22 09:20:441211<pre><tt>diff --cc file</tt></pre>
Junio C Hamano29f14312006-10-26 08:47:291212</div></div>
1213</li>
1214<li>
1215<p>
1216It is followed by one or more extended header lines
1217 (this example shows a merge with two parents):
1218</p>
1219<div class="literalblock">
1220<div class="content">
1221<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1222mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1223new file mode &lt;mode&gt;
1224deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1225</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311226<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
Junio C Hamanoee1e4282007-02-04 08:32:041227the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291228information about detected contents movement (renames and
1229copying detection) are designed to work with diff of two
Junio C Hamanoba4b9282008-07-06 05:20:311230&lt;tree-ish&gt; and are not used by combined diff format.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291231</li>
1232<li>
1233<p>
1234It is followed by two-line from-file/to-file header
1235</p>
1236<div class="literalblock">
1237<div class="content">
1238<pre><tt>--- a/file
1239+++ b/file</tt></pre>
1240</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311241<div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
Junio C Hamano29f14312006-10-26 08:47:291242format, <tt>/dev/null</tt> is used to signal created or deleted
Junio C Hamanoba4b9282008-07-06 05:20:311243files.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291244</li>
1245<li>
1246<p>
1247Chunk header format is modified to prevent people from
1248 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1249 was created for review of merge commit changes, and was not
1250 meant for apply. The change is similar to the change in the
1251 extended <em>index</em> header:
1252</p>
1253<div class="literalblock">
1254<div class="content">
1255<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1256</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311257<div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1258header for combined diff format.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291259</li>
Junio C Hamanoba4b9282008-07-06 05:20:311260</ol></div>
1261<div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
Junio C Hamanofb56a962006-01-28 10:38:191262files A and B with a single column that has <tt>-</tt> (minus &#8212;
1263appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291264added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191265compares two or more files file1, file2,&#8230; with one file X, and
1266shows how X differs from each of fileN. One column for each of
1267fileN is prepended to the output line to note how X's line is
Junio C Hamanoba4b9282008-07-06 05:20:311268different from it.</p></div>
1269<div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291270fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamano54bf1e22008-12-20 06:30:111271in the column N means that the line appears in the result,
Junio C Hamano29f14312006-10-26 08:47:291272and fileN does not have that line (in other words, the line was
Junio C Hamanoba4b9282008-07-06 05:20:311273added, from the point of view of that parent).</p></div>
1274<div class="para"><p>In the above example output, the function signature was changed
Junio C Hamanofb56a962006-01-28 10:38:191275from both files (hence two <tt>-</tt> removals from both file1 and
Junio C Hamano4604fe52008-09-19 06:37:101276file2, plus <tt>++</tt> to mean one line that was added does not appear
Junio C Hamano54bf1e22008-12-20 06:30:111277in either file1 nor file2). Also eight other lines are the same
1278from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311279<div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
Junio C Hamanofb56a962006-01-28 10:38:191280merge commit with the merge result (i.e. file1..fileN are the
1281parents). When shown by <tt>git diff-files -c</tt>, it compares the
1282two unresolved merge parents with the working tree file
1283(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
Junio C Hamanoba4b9282008-07-06 05:20:311284"their version").</p></div>
Junio C Hamanofb56a962006-01-28 10:38:191285</div>
Junio C Hamanoba4b9282008-07-06 05:20:311286<h2 id="_other_diff_formats">other diff formats</h2>
Junio C Hamano3a702342007-12-12 21:34:021287<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311288<div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
Junio C Hamano3a702342007-12-12 21:34:021289copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1290output. These options can be combined with other options, such as
Junio C Hamanoba4b9282008-07-06 05:20:311291<tt>-p</tt>, and are meant for human consumption.</p></div>
1292<div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
Junio C Hamano3a702342007-12-12 21:34:021293formats the pathnames compactly by combining common prefix and suffix of
1294the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
Junio C Hamanoba4b9282008-07-06 05:20:311295<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021296<div class="listingblock">
1297<div class="content">
1298<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1299</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311300<div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
Junio C Hamano3a702342007-12-12 21:34:021301for easier machine consumption. An entry in <tt>--numstat</tt> output looks
Junio C Hamanoba4b9282008-07-06 05:20:311302like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021303<div class="listingblock">
1304<div class="content">
1305<pre><tt>1 2 README
13063 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1307</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311308<div class="para"><p>That is, from left to right:</p></div>
1309<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021310<li>
1311<p>
1312the number of added lines;
1313</p>
1314</li>
1315<li>
1316<p>
1317a tab;
1318</p>
1319</li>
1320<li>
1321<p>
1322the number of deleted lines;
1323</p>
1324</li>
1325<li>
1326<p>
1327a tab;
1328</p>
1329</li>
1330<li>
1331<p>
1332pathname (possibly with rename/copy information);
1333</p>
1334</li>
1335<li>
1336<p>
1337a newline.
1338</p>
1339</li>
Junio C Hamanoba4b9282008-07-06 05:20:311340</ol></div>
1341<div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021342<div class="listingblock">
1343<div class="content">
1344<pre><tt>1 2 README NUL
13453 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1346</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311347<div class="para"><p>That is:</p></div>
1348<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021349<li>
1350<p>
1351the number of added lines;
1352</p>
1353</li>
1354<li>
1355<p>
1356a tab;
1357</p>
1358</li>
1359<li>
1360<p>
1361the number of deleted lines;
1362</p>
1363</li>
1364<li>
1365<p>
1366a tab;
1367</p>
1368</li>
1369<li>
1370<p>
1371a NUL (only exists if renamed/copied);
1372</p>
1373</li>
1374<li>
1375<p>
1376pathname in preimage;
1377</p>
1378</li>
1379<li>
1380<p>
1381a NUL (only exists if renamed/copied);
1382</p>
1383</li>
1384<li>
1385<p>
1386pathname in postimage (only exists if renamed/copied);
1387</p>
1388</li>
1389<li>
1390<p>
1391a NUL.
1392</p>
1393</li>
Junio C Hamanoba4b9282008-07-06 05:20:311394</ol></div>
1395<div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
Junio C Hamano3a702342007-12-12 21:34:021396scripts that read the output to tell if the current record being read is
1397a single-path record or a rename/copy record without reading ahead.
1398After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
Junio C Hamanoba4b9282008-07-06 05:20:311399the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
Junio C Hamano3a702342007-12-12 21:34:021400</div>
Junio C Hamanoba4b9282008-07-06 05:20:311401<h2 id="_operating_modes">Operating Modes</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231402<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311403<div class="para"><p>You can choose whether you want to trust the index file entirely
Junio C Hamano1a4e8412005-12-27 08:17:231404(using the <em>--cached</em> flag) or ask the diff logic to show any files
1405that don't match the stat state as being "tentatively changed". Both
Junio C Hamanoba4b9282008-07-06 05:20:311406of these operations are very useful indeed.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231407</div>
Junio C Hamanoba4b9282008-07-06 05:20:311408<h2 id="_cached_mode">Cached Mode</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231409<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311410<div class="para"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231411<div class="literalblock">
1412<div class="content">
1413<pre><tt>show me the differences between HEAD and the current index
Junio C Hamano1aa40d22010-01-21 17:46:431414contents (the ones I'd write using 'git write-tree')</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231415</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311416<div class="para"><p>For example, let's say that you have worked on your working directory, updated
Junio C Hamano235a91e2006-01-07 01:13:581417some files in the index and are ready to commit. You want to see exactly
Junio C Hamanodcc22ee2006-11-03 02:40:131418<strong>what</strong> you are going to commit, without having to write a new tree
Junio C Hamanoba4b9282008-07-06 05:20:311419object and compare it that way, and to do that, you just do</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231420<div class="literalblock">
1421<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381422<pre><tt>git diff-index --cached HEAD</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231423</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311424<div class="para"><p>Example: let's say I had renamed <tt>commit.c</tt> to <tt>git-commit.c</tt>, and I had
Junio C Hamanofce7c7e2008-07-02 03:06:381425done an <tt>update-index</tt> to make that effective in the index file.
1426<tt>git diff-files</tt> wouldn't show anything at all, since the index file
Junio C Hamano1aa40d22010-01-21 17:46:431427matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231428<div class="literalblock">
1429<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381430<pre><tt>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
Junio C Hamano1a4e8412005-12-27 08:17:231431-100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1432+100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre>
1433</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311434<div class="para"><p>You can see easily that the above is a rename.</p></div>
1435<div class="para"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to
Junio C Hamano1aa40d22010-01-21 17:46:431436actually doing a <em>git write-tree</em> and comparing that. Except this one is much
Junio C Hamanoba4b9282008-07-06 05:20:311437nicer for the case where you just want to check where you are.</p></div>
Junio C Hamano1aa40d22010-01-21 17:46:431438<div class="para"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are
Junio C Hamano1a4e8412005-12-27 08:17:231439asking yourself "what have I already marked for being committed, and
Junio C Hamanoba4b9282008-07-06 05:20:311440what's the difference to a previous tree".</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231441</div>
Junio C Hamanoba4b9282008-07-06 05:20:311442<h2 id="_non_cached_mode">Non-cached Mode</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231443<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311444<div class="para"><p>The "non-cached" mode takes a different approach, and is potentially
Junio C Hamano1a4e8412005-12-27 08:17:231445the more useful of the two in that what it does can't be emulated with
Junio C Hamano1aa40d22010-01-21 17:46:431446a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that's the default mode.
Junio C Hamanoba4b9282008-07-06 05:20:311447The non-cached version asks the question:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231448<div class="literalblock">
1449<div class="content">
1450<pre><tt>show me the differences between HEAD and the currently checked out
1451tree - index contents _and_ files that aren't up-to-date</tt></pre>
1452</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311453<div class="para"><p>which is obviously a very useful question too, since that tells you what
Junio C Hamano1aa40d22010-01-21 17:46:431454you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
Junio C Hamanoba4b9282008-07-06 05:20:311455output to a tee, but with a twist.</p></div>
1456<div class="para"><p>The twist is that if some file doesn't match the index, we don't have
Junio C Hamano1a4e8412005-12-27 08:17:231457a backing store thing for it, and we use the magic "all-zero" sha1 to
1458show that. So let's say that you have edited <tt>kernel/sched.c</tt>, but
Junio C Hamano1aa40d22010-01-21 17:46:431459have not actually done a <em>git update-index</em> on it yet - there is no
Junio C Hamanoba4b9282008-07-06 05:20:311460"object" associated with the new state, and you get:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231461<div class="literalblock">
1462<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381463<pre><tt>torvalds@ppc970:~/v2.6/linux&gt; git diff-index HEAD
Junio C Hamano1a4e8412005-12-27 08:17:231464*100644-&gt;100664 blob 7476bb......-&gt;000000...... kernel/sched.c</tt></pre>
1465</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311466<div class="para"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is
Junio C Hamano1a4e8412005-12-27 08:17:231467not up-to-date and may contain new stuff. The all-zero sha1 means that to
1468get the real diff, you need to look at the object in the working directory
Junio C Hamanoba4b9282008-07-06 05:20:311469directly rather than do an object-to-object diff.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231470<div class="admonitionblock">
1471<table><tr>
1472<td class="icon">
1473<div class="title">Note</div>
1474</td>
Junio C Hamano1aa40d22010-01-21 17:46:431475<td class="content">As with other commands of this type, <em>git diff-index</em> does not
Junio C Hamano1a4e8412005-12-27 08:17:231476actually look at the contents of the file at all. So maybe
1477<tt>kernel/sched.c</tt> hasn't actually changed, and it's just that you
1478touched it. In either case, it's a note that you need to
Junio C Hamano1aa40d22010-01-21 17:46:431479<em>git update-index</em> it to make the index be in sync.</td>
Junio C Hamano1a4e8412005-12-27 08:17:231480</tr></table>
1481</div>
1482<div class="admonitionblock">
1483<table><tr>
1484<td class="icon">
1485<div class="title">Note</div>
1486</td>
1487<td class="content">You can have a mixture of files show up as "has been updated"
1488and "is still dirty in the working directory" together. You can always
1489tell which file is in which state, since the "has been updated" ones
1490show a valid sha1, and the "not in sync with the index" ones will
1491always have the special all-zero sha1.</td>
1492</tr></table>
1493</div>
1494</div>
Junio C Hamanoba4b9282008-07-06 05:20:311495<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231496<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311497<div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231498</div>
Junio C Hamanoba4b9282008-07-06 05:20:311499<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231500<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311501<div class="para"><p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231502</div>
Junio C Hamanoba4b9282008-07-06 05:20:311503<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231504<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311505<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231506</div>
1507<div id="footer">
1508<div id="footer-text">
Junio C Hamano1aa40d22010-01-21 17:46:431509Last updated 2010-01-21 17:44:26 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231510</div>
1511</div>
1512</body>
1513</html>