blob: 8474fd83b62003682dce005f15e2c94aee13521f [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 Hamano0868a302008-07-22 09:20:446<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 Hamano0868a302008-07-22 09:20:4419a {
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 Hamano0868a302008-07-22 09:20:4447h1, 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 Hamano0868a302008-07-22 09:20:4453h3 {
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 Hamano0868a302008-07-22 09:20:4483 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 Hamano0868a302008-07-22 09:20:44152div.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 Hamano0868a302008-07-22 09:20:44164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamano0868a302008-07-22 09:20:44168div.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 Hamano0868a302008-07-22 09:20:44214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamano0868a302008-07-22 09:20:44219 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 Hamano0868a302008-07-22 09:20:44233div.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 Hamano0868a302008-07-22 09:20:44248
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 Hamano0868a302008-07-22 09:20:44303
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(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-diff(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-diff -
Junio C Hamano01078922006-03-10 00:31:47317 Show changes between commits, commit and working tree, etc
Junio C Hamano1a4e8412005-12-27 08:17:23318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44323<div class="para"><p><em>git diff</em> [&lt;common diff options&gt;] &lt;commit&gt;{0,2} [--] [&lt;path&gt;&#8230;]</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23324</div>
Junio C Hamano0868a302008-07-22 09:20:44325<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23326<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44327<div class="para"><p>Show changes between two trees, a tree and the working tree, a
328tree and the index file, or the index file and the working tree.</p></div>
329<div class="vlist"><dl>
Junio C Hamano47848ae2006-12-14 11:20:06330<dt>
Junio C Hamanofce7c7e2008-07-02 03:06:38331<em>git diff</em> [--options] [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06332</dt>
333<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23334<p>
Junio C Hamano47848ae2006-12-14 11:20:06335 This form is to view the changes you made relative to
336 the index (staging area for the next commit). In other
Junio C Hamano4604fe52008-09-19 06:37:10337 words, the differences are what you _could_ tell git to
Junio C Hamano47848ae2006-12-14 11:20:06338 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>.
Junio C Hamano1a4e8412005-12-27 08:17:23340</p>
Junio C Hamano0868a302008-07-22 09:20:44341<div class="para"><p>If exactly two paths are given, and at least one is untracked,
Junio C Hamanodb911ee2007-02-28 08:13:52342compare the two files / directories. This behavior can be
Junio C Hamano0868a302008-07-22 09:20:44343forced by --no-index.</p></div>
Junio C Hamano47848ae2006-12-14 11:20:06344</dd>
345<dt>
Junio C Hamanofce7c7e2008-07-02 03:06:38346<em>git diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06347</dt>
348<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23349<p>
Junio C Hamano47848ae2006-12-14 11:20:06350 This form is to view the changes you staged for the next
Junio C Hamano4bf6dca2006-12-21 02:25:57351 commit relative to the named &lt;commit&gt;. Typically you
Junio C Hamano47848ae2006-12-14 11:20:06352 would want comparison with the latest commit, so if you
353 do not give &lt;commit&gt;, it defaults to HEAD.
Junio C Hamano8b4977b2008-11-12 04:57:48354 --staged is a synonym of --cached.
Junio C Hamano1a4e8412005-12-27 08:17:23355</p>
Junio C Hamano47848ae2006-12-14 11:20:06356</dd>
357<dt>
Junio C Hamanofce7c7e2008-07-02 03:06:38358<em>git diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06359</dt>
360<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23361<p>
Junio C Hamano47848ae2006-12-14 11:20:06362 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.
Junio C Hamano1a4e8412005-12-27 08:17:23367</p>
Junio C Hamano47848ae2006-12-14 11:20:06368</dd>
369<dt>
Junio C Hamanofce7c7e2008-07-02 03:06:38370<em>git diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06371</dt>
372<dd>
373<p>
Junio C Hamanoc435b1c2007-08-28 06:25:35374 This is to view the changes between two arbitrary
375 &lt;commit&gt;.
376</p>
377</dd>
378<dt>
Junio C Hamanofce7c7e2008-07-02 03:06:38379<em>git diff</em> [--options] &lt;commit&gt;..&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamanoc435b1c2007-08-28 06:25:35380</dt>
381<dd>
382<p>
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>
Junio C Hamanofce7c7e2008-07-02 03:06:38389<em>git diff</em> [--options] &lt;commit&gt;...&lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamanoc435b1c2007-08-28 06:25:35390</dt>
391<dd>
392<p>
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
Junio C Hamanofce7c7e2008-07-02 03:06:38395 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
Junio C Hamanoc435b1c2007-08-28 06:25:35397 of &lt;commit&gt;, which has the same effect as using HEAD instead.
Junio C Hamano47848ae2006-12-14 11:20:06398</p>
399</dd>
Junio C Hamano0868a302008-07-22 09:20:44400</dl></div>
401<div class="para"><p>Just in case if you are doing something exotic, it should be
Junio C Hamano7d9e9bd2007-08-29 07:31:47402noted that all of the &lt;commit&gt; in the above description, except
403for the last two forms that use ".." notations, can be any
Junio C Hamano0868a302008-07-22 09:20:44404&lt;tree-ish&gt;.</p></div>
405<div class="para"><p>For a more complete list of ways to spell &lt;commit&gt;, see
Junio C Hamanoc435b1c2007-08-28 06:25:35406"SPECIFYING REVISIONS" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.
Junio C Hamano4604fe52008-09-19 06:37:10407However, "diff" is about comparing two _endpoints_, not ranges,
Junio C Hamanoc435b1c2007-08-28 06:25:35408and the range notations ("&lt;commit&gt;..&lt;commit&gt;" and
Junio C Hamano7d9e9bd2007-08-29 07:31:47409"&lt;commit&gt;...&lt;commit&gt;") do not mean a range as defined in the
Junio C Hamano0868a302008-07-22 09:20:44410"SPECIFYING RANGES" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23411</div>
Junio C Hamano0868a302008-07-22 09:20:44412<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23413<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44414<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23415<dt>
Junio C Hamano47848ae2006-12-14 11:20:06416-p
Junio C Hamano1a4e8412005-12-27 08:17:23417</dt>
418<dd>
419<p>
Junio C Hamanoff979792007-11-16 10:11:30420 Generate patch (see section on generating patches).
421 This is the default.
Junio C Hamano1a4e8412005-12-27 08:17:23422</p>
423</dd>
424<dt>
Junio C Hamano47848ae2006-12-14 11:20:06425-u
426</dt>
427<dd>
428<p>
429 Synonym for "-p".
430</p>
431</dd>
432<dt>
Junio C Hamano69361562007-07-26 02:14:34433-U&lt;n&gt;
434</dt>
435<dd>
436<p>
437 Shorthand for "--unified=&lt;n&gt;".
438</p>
439</dd>
440<dt>
441--unified=&lt;n&gt;
442</dt>
443<dd>
444<p>
445 Generate diffs with &lt;n&gt; lines of context instead of
446 the usual three. Implies "-p".
447</p>
448</dd>
449<dt>
Junio C Hamano47848ae2006-12-14 11:20:06450--raw
451</dt>
452<dd>
453<p>
454 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30455
Junio C Hamano47848ae2006-12-14 11:20:06456</p>
457</dd>
458<dt>
459--patch-with-raw
460</dt>
461<dd>
462<p>
463 Synonym for "-p --raw".
464</p>
465</dd>
466<dt>
467--stat[=width[,name-width]]
468</dt>
469<dd>
470<p>
471 Generate a diffstat. You can override the default
472 output width for 80-column terminal by "--stat=width".
473 The width of the filename part can be controlled by
474 giving another width to it separated by a comma.
475</p>
476</dd>
477<dt>
478--numstat
479</dt>
480<dd>
481<p>
482 Similar to --stat, but shows number of added and
483 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43484 abbreviation, to make it more machine friendly. For
485 binary files, outputs two <tt>-</tt> instead of saying
486 <tt>0 0</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06487</p>
488</dd>
489<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04490--shortstat
491</dt>
492<dd>
493<p>
494 Output only the last line of the --stat format containing total
495 number of modified files, as well as number of added and deleted
496 lines.
497</p>
498</dd>
499<dt>
Junio C Hamano6a45be92008-04-22 08:19:03500--dirstat[=limit]
501</dt>
502<dd>
503<p>
Junio C Hamanoa2f46622008-09-03 05:20:31504 Output the distribution of relative amount of changes (number of lines added or
505 removed) for each sub-directory. Directories with changes below
506 a cut-off percent (3% by default) are not shown. The cut-off percent
507 can be set with "--dirstat=limit". Changes in a child directory is not
508 counted for the parent directory, unless "--cumulative" is used.
Junio C Hamano6a45be92008-04-22 08:19:03509</p>
510</dd>
511<dt>
Junio C Hamanoa476efa2008-10-10 15:31:42512--dirstat-by-file[=limit]
513</dt>
514<dd>
515<p>
516 Same as --dirstat, but counts changed files instead of lines.
517</p>
518</dd>
519<dt>
Junio C Hamano47848ae2006-12-14 11:20:06520--summary
521</dt>
522<dd>
523<p>
524 Output a condensed summary of extended header information
525 such as creations, renames and mode changes.
526</p>
527</dd>
528<dt>
529--patch-with-stat
530</dt>
531<dd>
532<p>
533 Synonym for "-p --stat".
Junio C Hamanoff979792007-11-16 10:11:30534
Junio C Hamano47848ae2006-12-14 11:20:06535</p>
536</dd>
537<dt>
538-z
539</dt>
540<dd>
541<p>
Junio C Hamanob968dbb2007-07-27 07:26:40542 NUL-line termination on output. This affects the --raw
543 output field terminator. Also output from commands such
544 as "git-log" will be delimited with NUL between commits.
Junio C Hamano47848ae2006-12-14 11:20:06545</p>
546</dd>
547<dt>
548--name-only
549</dt>
550<dd>
551<p>
552 Show only names of changed files.
553</p>
554</dd>
555<dt>
556--name-status
557</dt>
558<dd>
559<p>
Junio C Hamanoa9aee782008-04-23 16:09:20560 Show only names and status of changed files. See the description
561 of the <tt>--diff-filter</tt> option on what the status letters mean.
Junio C Hamano47848ae2006-12-14 11:20:06562</p>
563</dd>
564<dt>
565--color
566</dt>
567<dd>
568<p>
569 Show colored diff.
570</p>
571</dd>
572<dt>
573--no-color
574</dt>
575<dd>
576<p>
577 Turn off colored diff, even when the configuration file
578 gives the default to color output.
579</p>
580</dd>
581<dt>
582--color-words
583</dt>
584<dd>
585<p>
586 Show colored word diff, i.e. color words which have changed.
587</p>
588</dd>
589<dt>
590--no-renames
591</dt>
592<dd>
593<p>
594 Turn off rename detection, even when the configuration
595 file gives the default to do so.
596</p>
597</dd>
598<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21599--check
600</dt>
601<dd>
602<p>
603 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54604 or an indent that uses a space before a tab. Exits with
605 non-zero status if problems are found. Not compatible with
606 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21607</p>
608</dd>
609<dt>
Junio C Hamano47848ae2006-12-14 11:20:06610--full-index
611</dt>
612<dd>
613<p>
Junio C Hamano5cf43ca2008-08-20 09:14:14614 Instead of the first handful of characters, show the full
615 pre- and post-image blob object names on the "index"
616 line when generating patch format output.
Junio C Hamano47848ae2006-12-14 11:20:06617</p>
618</dd>
619<dt>
620--binary
621</dt>
622<dd>
623<p>
624 In addition to --full-index, output "binary diff" that
625 can be applied with "git apply".
626</p>
627</dd>
628<dt>
629--abbrev[=&lt;n&gt;]
630</dt>
631<dd>
632<p>
633 Instead of showing the full 40-byte hexadecimal object
634 name in diff-raw format output and diff-tree header
635 lines, show only handful hexdigits prefix. This is
636 independent of --full-index option above, which controls
637 the diff-patch output format. Non default number of
638 digits can be specified with --abbrev=&lt;n&gt;.
639</p>
640</dd>
641<dt>
642-B
643</dt>
644<dd>
645<p>
646 Break complete rewrite changes into pairs of delete and create.
647</p>
648</dd>
649<dt>
650-M
651</dt>
652<dd>
653<p>
654 Detect renames.
655</p>
656</dd>
657<dt>
658-C
659</dt>
660<dd>
661<p>
Junio C Hamano16f98872007-06-12 16:09:14662 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06663</p>
664</dd>
665<dt>
666--diff-filter=[ACDMRTUXB*]
667</dt>
668<dd>
669<p>
670 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
671 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
Junio C Hamanoa2deec52008-10-18 18:58:09672 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
673 are Unmerged (<tt>U</tt>), are
Junio C Hamano47848ae2006-12-14 11:20:06674 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
675 Any combination of the filter characters may be used.
676 When <tt>*</tt> (All-or-none) is added to the combination, all
677 paths are selected if there is any file that matches
678 other criteria in the comparison; if there is no file
679 that matches other criteria, nothing is selected.
680</p>
681</dd>
682<dt>
683--find-copies-harder
684</dt>
685<dd>
686<p>
Junio C Hamano16f98872007-06-12 16:09:14687 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano47848ae2006-12-14 11:20:06688 if the original file of the copy was modified in the same
689 changeset. This flag makes the command
690 inspect unmodified files as candidates for the source of
691 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14692 projects, so use it with caution. Giving more than one
693 <tt>-C</tt> option has the same effect.
Junio C Hamano47848ae2006-12-14 11:20:06694</p>
695</dd>
696<dt>
697-l&lt;num&gt;
698</dt>
699<dd>
700<p>
701 -M and -C options require O(n^2) processing time where n
702 is the number of potential rename/copy targets. This
703 option prevents rename/copy detection from running if
704 the number of rename/copy targets exceeds the specified
705 number.
706</p>
707</dd>
708<dt>
709-S&lt;string&gt;
710</dt>
711<dd>
712<p>
713 Look for differences that contain the change in &lt;string&gt;.
714</p>
715</dd>
716<dt>
717--pickaxe-all
718</dt>
719<dd>
720<p>
721 When -S finds a change, show all the changes in that
722 changeset, not just the files that contain the change
723 in &lt;string&gt;.
724</p>
725</dd>
726<dt>
727--pickaxe-regex
728</dt>
729<dd>
730<p>
731 Make the &lt;string&gt; not a plain string but an extended POSIX
732 regex to match.
733</p>
734</dd>
735<dt>
736-O&lt;orderfile&gt;
737</dt>
738<dd>
739<p>
740 Output the patch in the order specified in the
741 &lt;orderfile&gt;, which has one shell glob pattern per line.
742</p>
743</dd>
744<dt>
745-R
746</dt>
747<dd>
748<p>
749 Swap two inputs; that is, show differences from index or
750 on-disk file to tree contents.
751</p>
752</dd>
753<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44754--relative[=&lt;path&gt;]
755</dt>
756<dd>
757<p>
758 When run from a subdirectory of the project, it can be
759 told to exclude changes outside the directory and show
760 pathnames relative to it with this option. When you are
761 not in a subdirectory (e.g. in a bare repository), you
762 can name which subdirectory to make the output relative
763 to by giving a &lt;path&gt; as an argument.
764</p>
765</dd>
766<dt>
Junio C Hamano47848ae2006-12-14 11:20:06767--text
768</dt>
769<dd>
770<p>
771 Treat all files as text.
772</p>
773</dd>
774<dt>
775-a
776</dt>
777<dd>
778<p>
779 Shorthand for "--text".
780</p>
781</dd>
782<dt>
Junio C Hamanofd468962007-02-14 23:45:04783--ignore-space-at-eol
784</dt>
785<dd>
786<p>
Junio C Hamano3a702342007-12-12 21:34:02787 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04788</p>
789</dd>
790<dt>
Junio C Hamano47848ae2006-12-14 11:20:06791--ignore-space-change
792</dt>
793<dd>
794<p>
Junio C Hamano3a702342007-12-12 21:34:02795 Ignore changes in amount of whitespace. This ignores whitespace
796 at line end, and considers all other sequences of one or
797 more whitespace characters to be equivalent.
Junio C Hamano47848ae2006-12-14 11:20:06798</p>
799</dd>
800<dt>
801-b
802</dt>
803<dd>
804<p>
805 Shorthand for "--ignore-space-change".
806</p>
807</dd>
808<dt>
809--ignore-all-space
810</dt>
811<dd>
812<p>
Junio C Hamano3a702342007-12-12 21:34:02813 Ignore whitespace when comparing lines. This ignores
814 differences even if one line has whitespace where the other
Junio C Hamano47848ae2006-12-14 11:20:06815 line has none.
816</p>
817</dd>
818<dt>
819-w
820</dt>
821<dd>
822<p>
823 Shorthand for "--ignore-all-space".
824</p>
825</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30826<dt>
827--exit-code
828</dt>
829<dd>
830<p>
831 Make the program exit with codes similar to diff(1).
832 That is, it exits with 1 if there were differences and
833 0 means no differences.
834</p>
835</dd>
Junio C Hamano35e57552007-03-25 07:54:35836<dt>
837--quiet
838</dt>
839<dd>
840<p>
841 Disable all output of the program. Implies --exit-code.
842</p>
843</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40844<dt>
845--ext-diff
846</dt>
847<dd>
848<p>
849 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53850 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
851 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40852</p>
853</dd>
854<dt>
855--no-ext-diff
856</dt>
857<dd>
858<p>
859 Disallow external diff drivers.
860</p>
861</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33862<dt>
Junio C Hamanodfccbb02008-05-26 01:16:14863--ignore-submodules
864</dt>
865<dd>
866<p>
867 Ignore changes to submodules in the diff generation.
868</p>
869</dd>
870<dt>
Junio C Hamanoe27cbd22007-12-21 17:57:33871--src-prefix=&lt;prefix&gt;
872</dt>
873<dd>
874<p>
875 Show the given source prefix instead of "a/".
876</p>
877</dd>
878<dt>
879--dst-prefix=&lt;prefix&gt;
880</dt>
881<dd>
882<p>
883 Show the given destination prefix instead of "b/".
884</p>
885</dd>
886<dt>
887--no-prefix
888</dt>
889<dd>
890<p>
891 Do not show any source or destination prefix.
892</p>
893</dd>
Junio C Hamano0868a302008-07-22 09:20:44894</dl></div>
895<div class="para"><p>For more detailed explanation on these common options, see also
896<a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
897<div class="vlist"><dl>
Junio C Hamano47848ae2006-12-14 11:20:06898<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23899&lt;path&gt;&#8230;
900</dt>
901<dd>
902<p>
Junio C Hamano47848ae2006-12-14 11:20:06903 The &lt;paths&gt; parameters, when given, are used to limit
904 the diff to the named paths (you can give directory
905 names and get diff for all files under them).
Junio C Hamano1a4e8412005-12-27 08:17:23906</p>
907</dd>
Junio C Hamano0868a302008-07-22 09:20:44908</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23909</div>
Junio C Hamano0868a302008-07-22 09:20:44910<h2 id="_output_format">Output format</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:46911<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44912<div class="para"><p>The output format from "git-diff-index", "git-diff-tree",
913"git-diff-files" and "git diff --raw" are very similar.</p></div>
914<div class="para"><p>These commands all compare two sets of things; what is
915compared differs:</p></div>
916<div class="vlist"><dl>
Junio C Hamano7ae0ab22007-11-03 02:46:46917<dt>
918git-diff-index &lt;tree-ish&gt;
919</dt>
920<dd>
921<p>
922 compares the &lt;tree-ish&gt; and the files on the filesystem.
923</p>
924</dd>
925<dt>
926git-diff-index --cached &lt;tree-ish&gt;
927</dt>
928<dd>
929<p>
930 compares the &lt;tree-ish&gt; and the index.
931</p>
932</dd>
933<dt>
934git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
935</dt>
936<dd>
937<p>
938 compares the trees named by the two arguments.
939</p>
940</dd>
941<dt>
942git-diff-files [&lt;pattern&gt;&#8230;]
943</dt>
944<dd>
945<p>
946 compares the index and the files on the filesystem.
947</p>
948</dd>
Junio C Hamano0868a302008-07-22 09:20:44949</dl></div>
950<div class="para"><p>An output line is formatted this way:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:46951<div class="listingblock">
952<div class="content">
953<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
954copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
955rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
956create :000000 100644 0000000... 1234567... A file4
957delete :100644 000000 1234567... 0000000... D file5
958unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
959</div></div>
Junio C Hamano0868a302008-07-22 09:20:44960<div class="para"><p>That is, from the left to the right:</p></div>
961<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:46962<li>
963<p>
964a colon.
965</p>
966</li>
967<li>
968<p>
969mode for "src"; 000000 if creation or unmerged.
970</p>
971</li>
972<li>
973<p>
974a space.
975</p>
976</li>
977<li>
978<p>
979mode for "dst"; 000000 if deletion or unmerged.
980</p>
981</li>
982<li>
983<p>
984a space.
985</p>
986</li>
987<li>
988<p>
989sha1 for "src"; 0{40} if creation or unmerged.
990</p>
991</li>
992<li>
993<p>
994a space.
995</p>
996</li>
997<li>
998<p>
999sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1000</p>
1001</li>
1002<li>
1003<p>
1004a space.
1005</p>
1006</li>
1007<li>
1008<p>
1009status, followed by optional "score" number.
1010</p>
1011</li>
1012<li>
1013<p>
1014a tab or a NUL when <em>-z</em> option is used.
1015</p>
1016</li>
1017<li>
1018<p>
1019path for "src"
1020</p>
1021</li>
1022<li>
1023<p>
1024a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1025</p>
1026</li>
1027<li>
1028<p>
1029path for "dst"; only exists for C or R.
1030</p>
1031</li>
1032<li>
1033<p>
1034an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1035</p>
1036</li>
Junio C Hamano0868a302008-07-22 09:20:441037</ol></div>
Junio C Hamanoaa17c7c2008-11-03 04:36:581038<div class="para"><p>Possible status letters are:</p></div>
1039<div class="ilist"><ul>
1040<li>
1041<p>
1042A: addition of a file
1043</p>
1044</li>
1045<li>
1046<p>
1047C: copy of a file into a new one
1048</p>
1049</li>
1050<li>
1051<p>
1052D: deletion of a file
1053</p>
1054</li>
1055<li>
1056<p>
1057M: modification of the contents or mode of a file
1058</p>
1059</li>
1060<li>
1061<p>
1062R: renaming of a file
1063</p>
1064</li>
1065<li>
1066<p>
1067T: change in the type of the file
1068</p>
1069</li>
1070<li>
1071<p>
1072U: file is unmerged (you must complete the merge before it can
1073be committed)
1074</p>
1075</li>
1076<li>
1077<p>
1078X: "unknown" change type (most probably a bug, please report it)
1079</p>
1080</li>
1081</ul></div>
Junio C Hamano54bf1e22008-12-20 06:30:111082<div class="para"><p>Status letters C and R are always followed by a score (denoting the
Junio C Hamanoaa17c7c2008-11-03 04:36:581083percentage of similarity between the source and target of the move or
1084copy), and are the only ones to be so.</p></div>
Junio C Hamano0868a302008-07-22 09:20:441085<div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1086and it is out of sync with the index.</p></div>
1087<div class="para"><p>Example:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461088<div class="listingblock">
1089<div class="content">
1090<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1091</div></div>
Junio C Hamano0868a302008-07-22 09:20:441092<div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
Junio C Hamano7ae0ab22007-11-03 02:46:461093in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
Junio C Hamano0868a302008-07-22 09:20:441094respectively.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461095</div>
Junio C Hamano0868a302008-07-22 09:20:441096<h2 id="_diff_format_for_merges">diff format for merges</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461097<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441098<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
Junio C Hamano7ae0ab22007-11-03 02:46:461099can take <em>-c</em> or <em>--cc</em> option
1100to generate diff output also for merge commits. The output differs
Junio C Hamano0868a302008-07-22 09:20:441101from the format described above in the following way:</p></div>
1102<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461103<li>
1104<p>
1105there is a colon for each parent
1106</p>
1107</li>
1108<li>
1109<p>
1110there are more "src" modes and "src" sha1
1111</p>
1112</li>
1113<li>
1114<p>
1115status is concatenated status characters for each parent
1116</p>
1117</li>
1118<li>
1119<p>
1120no optional "score" number
1121</p>
1122</li>
1123<li>
1124<p>
1125single path, only for "dst"
1126</p>
1127</li>
Junio C Hamano0868a302008-07-22 09:20:441128</ol></div>
1129<div class="para"><p>Example:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461130<div class="listingblock">
1131<div class="content">
1132<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1133</div></div>
Junio C Hamano0868a302008-07-22 09:20:441134<div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1135all parents.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461136</div>
Junio C Hamano0868a302008-07-22 09:20:441137<h2 id="_generating_patches_with_p">Generating patches with -p</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461138<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441139<div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491140with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1141"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461142do not produce the output described above; instead they produce a
1143patch file. You can customize the creation of such patches via the
Junio C Hamano0868a302008-07-22 09:20:441144GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1145<div class="para"><p>What the -p option produces is slightly different from the traditional
1146diff format.</p></div>
1147<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461148<li>
1149<p>
1150It is preceded with a "git diff" header, that looks like
1151 this:
1152</p>
1153<div class="literalblock">
1154<div class="content">
1155<pre><tt>diff --git a/file1 b/file2</tt></pre>
1156</div></div>
Junio C Hamano0868a302008-07-22 09:20:441157<div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
Junio C Hamano7ae0ab22007-11-03 02:46:461158involved. Especially, even for a creation or a deletion,
Junio C Hamano4604fe52008-09-19 06:37:101159<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
Junio C Hamano0868a302008-07-22 09:20:441160<div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
Junio C Hamano7ae0ab22007-11-03 02:46:461161name of the source file of the rename/copy and the name of
Junio C Hamano0868a302008-07-22 09:20:441162the file that rename/copy produces, respectively.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461163</li>
1164<li>
1165<p>
1166It is followed by one or more extended header lines:
1167</p>
1168<div class="literalblock">
1169<div class="content">
1170<pre><tt>old mode &lt;mode&gt;
1171new mode &lt;mode&gt;
1172deleted file mode &lt;mode&gt;
1173new file mode &lt;mode&gt;
1174copy from &lt;path&gt;
1175copy to &lt;path&gt;
1176rename from &lt;path&gt;
1177rename to &lt;path&gt;
1178similarity index &lt;number&gt;
1179dissimilarity index &lt;number&gt;
1180index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1181</div></div>
1182</li>
1183<li>
1184<p>
1185TAB, LF, double quote and backslash characters in pathnames
1186 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1187 If there is need for such substitution then the whole
1188 pathname is put in double quotes.
1189</p>
1190</li>
Junio C Hamano0868a302008-07-22 09:20:441191</ol></div>
1192<div class="para"><p>The similarity index is the percentage of unchanged lines, and
Junio C Hamano7ae0ab22007-11-03 02:46:461193the dissimilarity index is the percentage of changed lines. It
1194is a rounded down integer, followed by a percent sign. The
1195similarity index value of 100% is thus reserved for two equal
1196files, while 100% dissimilarity means that no line from the old
Junio C Hamano0868a302008-07-22 09:20:441197file made it into the new one.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461198</div>
Junio C Hamano0868a302008-07-22 09:20:441199<h2 id="_combined_diff_format">combined diff format</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461200<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441201<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:491202<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1203with "git log -p", this is the default format.
Junio C Hamano0868a302008-07-22 09:20:441204A <em>combined diff</em> format looks like this:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461205<div class="listingblock">
1206<div class="content">
1207<pre><tt>diff --combined describe.c
1208index fabadb8,cc95eb0..4866510
1209--- a/describe.c
1210+++ b/describe.c
1211@@@ -98,20 -98,12 +98,20 @@@
1212 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1213 }
1214
1215- static void describe(char *arg)
1216 -static void describe(struct commit *cmit, int last_one)
1217++static void describe(char *arg, int last_one)
1218 {
1219 + unsigned char sha1[20];
1220 + struct commit *cmit;
1221 struct commit_list *list;
1222 static int initialized = 0;
1223 struct commit_name *n;
1224
1225 + if (get_sha1(arg, sha1) &lt; 0)
1226 + usage(describe_usage);
1227 + cmit = lookup_commit_reference(sha1);
1228 + if (!cmit)
1229 + usage(describe_usage);
1230 +
1231 if (!initialized) {
1232 initialized = 1;
1233 for_each_ref(get_name);</tt></pre>
1234</div></div>
Junio C Hamano0868a302008-07-22 09:20:441235<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461236<li>
1237<p>
1238It is preceded with a "git diff" header, that looks like
1239 this (when <em>-c</em> option is used):
1240</p>
1241<div class="literalblock">
1242<div class="content">
1243<pre><tt>diff --combined file</tt></pre>
1244</div></div>
Junio C Hamano0868a302008-07-22 09:20:441245<div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461246<div class="literalblock">
1247<div class="content">
Junio C Hamano0868a302008-07-22 09:20:441248<pre><tt>diff --cc file</tt></pre>
Junio C Hamano7ae0ab22007-11-03 02:46:461249</div></div>
1250</li>
1251<li>
1252<p>
1253It is followed by one or more extended header lines
1254 (this example shows a merge with two parents):
1255</p>
1256<div class="literalblock">
1257<div class="content">
1258<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1259mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1260new file mode &lt;mode&gt;
1261deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1262</div></div>
Junio C Hamano0868a302008-07-22 09:20:441263<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 Hamano7ae0ab22007-11-03 02:46:461264the &lt;mode&gt; is different from the rest. Extended headers with
1265information about detected contents movement (renames and
1266copying detection) are designed to work with diff of two
Junio C Hamano0868a302008-07-22 09:20:441267&lt;tree-ish&gt; and are not used by combined diff format.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461268</li>
1269<li>
1270<p>
1271It is followed by two-line from-file/to-file header
1272</p>
1273<div class="literalblock">
1274<div class="content">
1275<pre><tt>--- a/file
1276+++ b/file</tt></pre>
1277</div></div>
Junio C Hamano0868a302008-07-22 09:20:441278<div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
Junio C Hamano7ae0ab22007-11-03 02:46:461279format, <tt>/dev/null</tt> is used to signal created or deleted
Junio C Hamano0868a302008-07-22 09:20:441280files.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461281</li>
1282<li>
1283<p>
1284Chunk header format is modified to prevent people from
1285 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1286 was created for review of merge commit changes, and was not
1287 meant for apply. The change is similar to the change in the
1288 extended <em>index</em> header:
1289</p>
1290<div class="literalblock">
1291<div class="content">
1292<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1293</div></div>
Junio C Hamano0868a302008-07-22 09:20:441294<div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1295header for combined diff format.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461296</li>
Junio C Hamano0868a302008-07-22 09:20:441297</ol></div>
1298<div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
Junio C Hamano7ae0ab22007-11-03 02:46:461299files A and B with a single column that has <tt>-</tt> (minus &#8212;
1300appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
1301added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
1302compares two or more files file1, file2,&#8230; with one file X, and
1303shows how X differs from each of fileN. One column for each of
1304fileN is prepended to the output line to note how X's line is
Junio C Hamano0868a302008-07-22 09:20:441305different from it.</p></div>
1306<div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano7ae0ab22007-11-03 02:46:461307fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamano54bf1e22008-12-20 06:30:111308in the column N means that the line appears in the result,
Junio C Hamano7ae0ab22007-11-03 02:46:461309and fileN does not have that line (in other words, the line was
Junio C Hamano0868a302008-07-22 09:20:441310added, from the point of view of that parent).</p></div>
1311<div class="para"><p>In the above example output, the function signature was changed
Junio C Hamano7ae0ab22007-11-03 02:46:461312from both files (hence two <tt>-</tt> removals from both file1 and
Junio C Hamano4604fe52008-09-19 06:37:101313file2, plus <tt>++</tt> to mean one line that was added does not appear
Junio C Hamano54bf1e22008-12-20 06:30:111314in either file1 nor file2). Also eight other lines are the same
1315from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
Junio C Hamano0868a302008-07-22 09:20:441316<div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
Junio C Hamano7ae0ab22007-11-03 02:46:461317merge commit with the merge result (i.e. file1..fileN are the
1318parents). When shown by <tt>git diff-files -c</tt>, it compares the
1319two unresolved merge parents with the working tree file
1320(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
Junio C Hamano0868a302008-07-22 09:20:441321"their version").</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461322</div>
Junio C Hamano0868a302008-07-22 09:20:441323<h2 id="_other_diff_formats">other diff formats</h2>
Junio C Hamano3a702342007-12-12 21:34:021324<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441325<div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
Junio C Hamano3a702342007-12-12 21:34:021326copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1327output. These options can be combined with other options, such as
Junio C Hamano0868a302008-07-22 09:20:441328<tt>-p</tt>, and are meant for human consumption.</p></div>
1329<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:021330formats the pathnames compactly by combining common prefix and suffix of
1331the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
Junio C Hamano0868a302008-07-22 09:20:441332<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021333<div class="listingblock">
1334<div class="content">
1335<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1336</div></div>
Junio C Hamano0868a302008-07-22 09:20:441337<div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
Junio C Hamano3a702342007-12-12 21:34:021338for easier machine consumption. An entry in <tt>--numstat</tt> output looks
Junio C Hamano0868a302008-07-22 09:20:441339like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021340<div class="listingblock">
1341<div class="content">
1342<pre><tt>1 2 README
13433 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1344</div></div>
Junio C Hamano0868a302008-07-22 09:20:441345<div class="para"><p>That is, from left to right:</p></div>
1346<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021347<li>
1348<p>
1349the number of added lines;
1350</p>
1351</li>
1352<li>
1353<p>
1354a tab;
1355</p>
1356</li>
1357<li>
1358<p>
1359the number of deleted lines;
1360</p>
1361</li>
1362<li>
1363<p>
1364a tab;
1365</p>
1366</li>
1367<li>
1368<p>
1369pathname (possibly with rename/copy information);
1370</p>
1371</li>
1372<li>
1373<p>
1374a newline.
1375</p>
1376</li>
Junio C Hamano0868a302008-07-22 09:20:441377</ol></div>
1378<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:021379<div class="listingblock">
1380<div class="content">
1381<pre><tt>1 2 README NUL
13823 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1383</div></div>
Junio C Hamano0868a302008-07-22 09:20:441384<div class="para"><p>That is:</p></div>
1385<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021386<li>
1387<p>
1388the number of added lines;
1389</p>
1390</li>
1391<li>
1392<p>
1393a tab;
1394</p>
1395</li>
1396<li>
1397<p>
1398the number of deleted lines;
1399</p>
1400</li>
1401<li>
1402<p>
1403a tab;
1404</p>
1405</li>
1406<li>
1407<p>
1408a NUL (only exists if renamed/copied);
1409</p>
1410</li>
1411<li>
1412<p>
1413pathname in preimage;
1414</p>
1415</li>
1416<li>
1417<p>
1418a NUL (only exists if renamed/copied);
1419</p>
1420</li>
1421<li>
1422<p>
1423pathname in postimage (only exists if renamed/copied);
1424</p>
1425</li>
1426<li>
1427<p>
1428a NUL.
1429</p>
1430</li>
Junio C Hamano0868a302008-07-22 09:20:441431</ol></div>
1432<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:021433scripts that read the output to tell if the current record being read is
1434a single-path record or a rename/copy record without reading ahead.
1435After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
Junio C Hamano0868a302008-07-22 09:20:441436the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
Junio C Hamano3a702342007-12-12 21:34:021437</div>
Junio C Hamano0868a302008-07-22 09:20:441438<h2 id="_examples">EXAMPLES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231439<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441440<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:231441<dt>
1442Various ways to check your working tree
1443</dt>
1444<dd>
1445<div class="listingblock">
1446<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011447<pre><tt>$ git diff <b>(1)</b>
Junio C Hamano47848ae2006-12-14 11:20:061448$ git diff --cached <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011449$ git diff HEAD <b>(3)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231450</div></div>
Junio C Hamano0868a302008-07-22 09:20:441451<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011452<li>
1453<p>
Junio C Hamano092f5f02007-08-02 07:23:381454Changes in the working tree not yet staged for the next commit.
Junio C Hamanoc8d88c22006-04-29 07:02:011455</p>
1456</li>
1457<li>
1458<p>
Junio C Hamano092f5f02007-08-02 07:23:381459Changes between the index and your last commit; what you
Junio C Hamanoc8d88c22006-04-29 07:02:011460would be committing if you run "git commit" without "-a" option.
1461</p>
1462</li>
1463<li>
1464<p>
Junio C Hamano092f5f02007-08-02 07:23:381465Changes in the working tree since your last commit; what you
Junio C Hamanoc8d88c22006-04-29 07:02:011466would be committing if you run "git commit -a"
1467</p>
1468</li>
Junio C Hamano0868a302008-07-22 09:20:441469</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231470</dd>
1471<dt>
1472Comparing with arbitrary commits
1473</dt>
1474<dd>
1475<div class="listingblock">
1476<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011477<pre><tt>$ git diff test <b>(1)</b>
1478$ git diff HEAD -- ./test <b>(2)</b>
1479$ git diff HEAD^ HEAD <b>(3)</b></tt></pre>
1480</div></div>
Junio C Hamano0868a302008-07-22 09:20:441481<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011482<li>
1483<p>
Junio C Hamano092f5f02007-08-02 07:23:381484Instead of using the tip of the current branch, compare with the
Junio C Hamano1a4e8412005-12-27 08:17:231485tip of "test" branch.
Junio C Hamanoc8d88c22006-04-29 07:02:011486</p>
1487</li>
1488<li>
1489<p>
Junio C Hamano092f5f02007-08-02 07:23:381490Instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:581491the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:231492file "test".
Junio C Hamanoc8d88c22006-04-29 07:02:011493</p>
1494</li>
1495<li>
1496<p>
Junio C Hamano092f5f02007-08-02 07:23:381497Compare the version before the last commit and the last commit.
Junio C Hamanoc8d88c22006-04-29 07:02:011498</p>
1499</li>
Junio C Hamano0868a302008-07-22 09:20:441500</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231501</dd>
1502<dt>
Junio C Hamanoc435b1c2007-08-28 06:25:351503Comparing branches
1504</dt>
1505<dd>
1506<div class="listingblock">
1507<div class="content">
1508<pre><tt>$ git diff topic master <b>(1)</b>
1509$ git diff topic..master <b>(2)</b>
1510$ git diff topic...master <b>(3)</b></tt></pre>
1511</div></div>
Junio C Hamano0868a302008-07-22 09:20:441512<div class="colist"><ol>
Junio C Hamanoc435b1c2007-08-28 06:25:351513<li>
1514<p>
1515Changes between the tips of the topic and the master branches.
1516</p>
1517</li>
1518<li>
1519<p>
1520Same as above.
1521</p>
1522</li>
1523<li>
1524<p>
Junio C Hamano764a6672007-10-23 01:23:311525Changes that occurred on the master branch since when the topic
Junio C Hamanoc435b1c2007-08-28 06:25:351526branch was started off it.
1527</p>
1528</li>
Junio C Hamano0868a302008-07-22 09:20:441529</ol></div>
Junio C Hamanoc435b1c2007-08-28 06:25:351530</dd>
1531<dt>
Junio C Hamano1a4e8412005-12-27 08:17:231532Limiting the diff output
1533</dt>
1534<dd>
1535<div class="listingblock">
1536<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011537<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>
Junio C Hamanobdeff822007-07-30 09:07:171538$ git diff --name-status <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011539$ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>
1540</div></div>
Junio C Hamano0868a302008-07-22 09:20:441541<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011542<li>
1543<p>
Junio C Hamano092f5f02007-08-02 07:23:381544Show only modification, rename and copy, but not addition
Junio C Hamano1a4e8412005-12-27 08:17:231545nor deletion.
Junio C Hamanoc8d88c22006-04-29 07:02:011546</p>
1547</li>
1548<li>
1549<p>
Junio C Hamano092f5f02007-08-02 07:23:381550Show only names and the nature of change, but not actual
Junio C Hamanobdeff822007-07-30 09:07:171551diff output.
Junio C Hamanoc8d88c22006-04-29 07:02:011552</p>
1553</li>
1554<li>
1555<p>
Junio C Hamano092f5f02007-08-02 07:23:381556Limit diff output to named subtrees.
Junio C Hamanoc8d88c22006-04-29 07:02:011557</p>
1558</li>
Junio C Hamano0868a302008-07-22 09:20:441559</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231560</dd>
1561<dt>
1562Munging the diff output
1563</dt>
1564<dd>
1565<div class="listingblock">
1566<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011567<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>
1568$ git diff -R <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231569</div></div>
Junio C Hamano0868a302008-07-22 09:20:441570<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011571<li>
1572<p>
Junio C Hamano092f5f02007-08-02 07:23:381573Spend extra cycles to find renames, copies and complete
Junio C Hamanoc8d88c22006-04-29 07:02:011574rewrites (very expensive).
1575</p>
1576</li>
1577<li>
1578<p>
Junio C Hamano092f5f02007-08-02 07:23:381579Output diff in reverse.
Junio C Hamanoc8d88c22006-04-29 07:02:011580</p>
1581</li>
Junio C Hamano0868a302008-07-22 09:20:441582</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231583</dd>
Junio C Hamano0868a302008-07-22 09:20:441584</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:231585</div>
Junio C Hamano0868a302008-07-22 09:20:441586<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231587<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441588<div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231589</div>
Junio C Hamano0868a302008-07-22 09:20:441590<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231591<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441592<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231593</div>
Junio C Hamano0868a302008-07-22 09:20:441594<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231595<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441596<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231597</div>
1598<div id="footer">
1599<div id="footer-text">
Junio C Hamano54bf1e22008-12-20 06:30:111600Last updated 2008-12-20 06:29:39 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231601</div>
1602</div>
1603</body>
1604</html>