blob: 850616994a0eab5220ca2dcb9e7cf11a283eab4e [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 Hamanoe1b26832009-11-15 10:02:56337 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 Hamanoe1b26832009-11-15 10:02:56407However, "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>
Junio C Hamanobbbb8652008-12-29 10:34:22418<dt>
419-u
420</dt>
Junio C Hamanoe97d5772010-05-19 08:13:58421<dt>
422--patch
423</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23424<dd>
425<p>
Junio C Hamanoff979792007-11-16 10:11:30426 Generate patch (see section on generating patches).
427 This is the default.
Junio C Hamano1a4e8412005-12-27 08:17:23428</p>
429</dd>
430<dt>
Junio C Hamano69361562007-07-26 02:14:34431-U&lt;n&gt;
432</dt>
Junio C Hamano69361562007-07-26 02:14:34433<dt>
434--unified=&lt;n&gt;
435</dt>
436<dd>
437<p>
438 Generate diffs with &lt;n&gt; lines of context instead of
Junio C Hamano3b70d3c2009-11-21 17:37:37439 the usual three.
440 Implies <tt>-p</tt>.
Junio C Hamano69361562007-07-26 02:14:34441</p>
442</dd>
443<dt>
Junio C Hamano47848ae2006-12-14 11:20:06444--raw
445</dt>
446<dd>
447<p>
448 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30449
Junio C Hamano47848ae2006-12-14 11:20:06450</p>
451</dd>
452<dt>
453--patch-with-raw
454</dt>
455<dd>
456<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37457 Synonym for <tt>-p --raw</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06458</p>
459</dd>
Junio C Hamano20d47e32009-01-26 06:36:02460<dt>
461--patience
462</dt>
463<dd>
464<p>
465 Generate a diff using the "patience diff" algorithm.
466</p>
467</dd>
Junio C Hamano47848ae2006-12-14 11:20:06468<dt>
469--stat[=width[,name-width]]
470</dt>
471<dd>
472<p>
473 Generate a diffstat. You can override the default
Junio C Hamano3b70d3c2009-11-21 17:37:37474 output width for 80-column terminal by <tt>--stat=width</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06475 The width of the filename part can be controlled by
476 giving another width to it separated by a comma.
477</p>
478</dd>
479<dt>
480--numstat
481</dt>
482<dd>
483<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37484 Similar to <tt>--stat</tt>, but shows number of added and
Junio C Hamano47848ae2006-12-14 11:20:06485 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43486 abbreviation, to make it more machine friendly. For
487 binary files, outputs two <tt>-</tt> instead of saying
488 <tt>0 0</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06489</p>
490</dd>
491<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04492--shortstat
493</dt>
494<dd>
495<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37496 Output only the last line of the <tt>--stat</tt> format containing total
Junio C Hamano7d23f5e2006-12-16 07:44:04497 number of modified files, as well as number of added and deleted
498 lines.
499</p>
500</dd>
501<dt>
Junio C Hamano6a45be92008-04-22 08:19:03502--dirstat[=limit]
503</dt>
504<dd>
505<p>
Junio C Hamanoa2f46622008-09-03 05:20:31506 Output the distribution of relative amount of changes (number of lines added or
507 removed) for each sub-directory. Directories with changes below
508 a cut-off percent (3% by default) are not shown. The cut-off percent
Junio C Hamano3b70d3c2009-11-21 17:37:37509 can be set with <tt>--dirstat=limit</tt>. Changes in a child directory is not
510 counted for the parent directory, unless <tt>--cumulative</tt> is used.
Junio C Hamano6a45be92008-04-22 08:19:03511</p>
512</dd>
513<dt>
Junio C Hamanoa476efa2008-10-10 15:31:42514--dirstat-by-file[=limit]
515</dt>
516<dd>
517<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37518 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
Junio C Hamanoa476efa2008-10-10 15:31:42519</p>
520</dd>
521<dt>
Junio C Hamano47848ae2006-12-14 11:20:06522--summary
523</dt>
524<dd>
525<p>
526 Output a condensed summary of extended header information
527 such as creations, renames and mode changes.
528</p>
529</dd>
530<dt>
531--patch-with-stat
532</dt>
533<dd>
534<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37535 Synonym for <tt>-p --stat</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06536</p>
537</dd>
538<dt>
539-z
540</dt>
541<dd>
542<p>
Junio C Hamano0c053e82010-04-19 06:46:34543 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
544 given, do not munge pathnames and use NULs as output field terminators.
Junio C Hamano47848ae2006-12-14 11:20:06545</p>
Junio C Hamano5706e0b2009-11-24 10:54:16546<div class="para"><p>Without this option, each pathname output will have TAB, LF, double quotes,
547and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
548respectively, and the pathname will be enclosed in double quotes if
549any of those replacements occurred.</p></div>
Junio C Hamano47848ae2006-12-14 11:20:06550</dd>
551<dt>
552--name-only
553</dt>
554<dd>
555<p>
556 Show only names of changed files.
557</p>
558</dd>
559<dt>
560--name-status
561</dt>
562<dd>
563<p>
Junio C Hamanoa9aee782008-04-23 16:09:20564 Show only names and status of changed files. See the description
565 of the <tt>--diff-filter</tt> option on what the status letters mean.
Junio C Hamano47848ae2006-12-14 11:20:06566</p>
567</dd>
568<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55569--submodule[=&lt;format&gt;]
570</dt>
571<dd>
572<p>
573 Chose the output format for submodule differences. &lt;format&gt; can be one of
574 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
575 is used when this option is not given. <em>log</em> is the default value for this
576 option and lists the commits in that commit range like the <em>summary</em>
577 option of <a href="git-submodule.html">git-submodule(1)</a> does.
578</p>
579</dd>
580<dt>
Junio C Hamano4aa0bcc2010-03-03 05:13:12581--color[=&lt;when&gt;]
Junio C Hamano47848ae2006-12-14 11:20:06582</dt>
583<dd>
584<p>
585 Show colored diff.
Junio C Hamano4aa0bcc2010-03-03 05:13:12586 The value must be always (the default), never, or auto.
Junio C Hamano47848ae2006-12-14 11:20:06587</p>
588</dd>
589<dt>
590--no-color
591</dt>
592<dd>
593<p>
594 Turn off colored diff, even when the configuration file
595 gives the default to color output.
Junio C Hamano4aa0bcc2010-03-03 05:13:12596 Same as <tt>--color=never</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06597</p>
598</dd>
599<dt>
Junio C Hamanocc7636a2010-05-21 14:57:53600--word-diff[=&lt;mode&gt;]
Junio C Hamano47848ae2006-12-14 11:20:06601</dt>
602<dd>
603<p>
Junio C Hamanocc7636a2010-05-21 14:57:53604 Show a word diff, using the &lt;mode&gt; to delimit changed words.
605 By default, words are delimited by whitespace; see
606 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
607 must be one of:
Junio C Hamano47848ae2006-12-14 11:20:06608</p>
Junio C Hamanocc7636a2010-05-21 14:57:53609<div class="vlist"><dl>
610<dt>
611color
612</dt>
613<dd>
614<p>
615 Highlight changed words using only colors. Implies <tt>--color</tt>.
616</p>
617</dd>
618<dt>
619plain
620</dt>
621<dd>
622<p>
623 Show words as <tt>[-removed-]</tt> and <tt>{+added+}</tt>. Makes no
624 attempts to escape the delimiters if they appear in the input,
625 so the output may be ambiguous.
626</p>
627</dd>
628<dt>
629porcelain
630</dt>
631<dd>
632<p>
633 Use a special line-based format intended for script
634 consumption. Added/removed/unchanged runs are printed in the
635 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/<tt> </tt>
636 character at the beginning of the line and extending to the
637 end of the line. Newlines in the input are represented by a
638 tilde <tt>~</tt> on a line of its own.
639</p>
640</dd>
641<dt>
642none
643</dt>
644<dd>
645<p>
646 Disable word diff again.
647</p>
648</dd>
649</dl></div>
650<div class="para"><p>Note that despite the name of the first mode, color is used to
651highlight the changed parts in all modes if enabled.</p></div>
652</dd>
653<dt>
654--word-diff-regex=&lt;regex&gt;
655</dt>
656<dd>
657<p>
658 Use &lt;regex&gt; to decide what a word is, instead of considering
659 runs of non-whitespace to be a word. Also implies
660 <tt>--word-diff</tt> unless it was already enabled.
661</p>
662<div class="para"><p>Every non-overlapping match of the
Junio C Hamano20d47e32009-01-26 06:36:02663&lt;regex&gt; is considered a word. Anything between these matches is
664considered whitespace and ignored(!) for the purposes of finding
665differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
666expression to make sure that it matches all non-whitespace characters.
667A match that contains a newline is silently truncated(!) at the
668newline.</p></div>
669<div class="para"><p>The regex can also be set via a diff driver or configuration option, see
670<a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
671overrides any diff driver or configuration setting. Diff drivers
672override configuration settings.</p></div>
Junio C Hamano47848ae2006-12-14 11:20:06673</dd>
674<dt>
Junio C Hamanocc7636a2010-05-21 14:57:53675--color-words[=&lt;regex&gt;]
676</dt>
677<dd>
678<p>
679 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
680 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
681</p>
682</dd>
683<dt>
Junio C Hamano47848ae2006-12-14 11:20:06684--no-renames
685</dt>
686<dd>
687<p>
688 Turn off rename detection, even when the configuration
689 file gives the default to do so.
690</p>
691</dd>
692<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21693--check
694</dt>
695<dd>
696<p>
697 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54698 or an indent that uses a space before a tab. Exits with
699 non-zero status if problems are found. Not compatible with
700 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21701</p>
702</dd>
703<dt>
Junio C Hamano47848ae2006-12-14 11:20:06704--full-index
705</dt>
706<dd>
707<p>
Junio C Hamano5cf43ca2008-08-20 09:14:14708 Instead of the first handful of characters, show the full
709 pre- and post-image blob object names on the "index"
710 line when generating patch format output.
Junio C Hamano47848ae2006-12-14 11:20:06711</p>
712</dd>
713<dt>
714--binary
715</dt>
716<dd>
717<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37718 In addition to <tt>--full-index</tt>, output a binary diff that
719 can be applied with <tt>git-apply</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06720</p>
721</dd>
722<dt>
723--abbrev[=&lt;n&gt;]
724</dt>
725<dd>
726<p>
727 Instead of showing the full 40-byte hexadecimal object
728 name in diff-raw format output and diff-tree header
Junio C Hamano6efe3022009-01-13 16:47:56729 lines, show only a partial prefix. This is
Junio C Hamano3b70d3c2009-11-21 17:37:37730 independent of the <tt>--full-index</tt> option above, which controls
Junio C Hamano47848ae2006-12-14 11:20:06731 the diff-patch output format. Non default number of
Junio C Hamano3b70d3c2009-11-21 17:37:37732 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06733</p>
734</dd>
735<dt>
736-B
737</dt>
738<dd>
739<p>
740 Break complete rewrite changes into pairs of delete and create.
741</p>
742</dd>
743<dt>
744-M
745</dt>
746<dd>
747<p>
748 Detect renames.
749</p>
750</dd>
751<dt>
752-C
753</dt>
754<dd>
755<p>
Junio C Hamano16f98872007-06-12 16:09:14756 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06757</p>
758</dd>
759<dt>
760--diff-filter=[ACDMRTUXB*]
761</dt>
762<dd>
763<p>
764 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
765 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
Junio C Hamanoa2deec52008-10-18 18:58:09766 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
767 are Unmerged (<tt>U</tt>), are
Junio C Hamano47848ae2006-12-14 11:20:06768 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
769 Any combination of the filter characters may be used.
770 When <tt>*</tt> (All-or-none) is added to the combination, all
771 paths are selected if there is any file that matches
772 other criteria in the comparison; if there is no file
773 that matches other criteria, nothing is selected.
774</p>
775</dd>
776<dt>
777--find-copies-harder
778</dt>
779<dd>
780<p>
Junio C Hamano16f98872007-06-12 16:09:14781 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano47848ae2006-12-14 11:20:06782 if the original file of the copy was modified in the same
783 changeset. This flag makes the command
784 inspect unmodified files as candidates for the source of
785 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14786 projects, so use it with caution. Giving more than one
787 <tt>-C</tt> option has the same effect.
Junio C Hamano47848ae2006-12-14 11:20:06788</p>
789</dd>
790<dt>
791-l&lt;num&gt;
792</dt>
793<dd>
794<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37795 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
Junio C Hamano47848ae2006-12-14 11:20:06796 is the number of potential rename/copy targets. This
797 option prevents rename/copy detection from running if
798 the number of rename/copy targets exceeds the specified
799 number.
800</p>
801</dd>
802<dt>
803-S&lt;string&gt;
804</dt>
805<dd>
806<p>
Junio C Hamano5217a272009-03-21 00:39:33807 Look for differences that introduce or remove an instance of
808 &lt;string&gt;. Note that this is different than the string simply
809 appearing in diff output; see the <em>pickaxe</em> entry in
810 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
Junio C Hamano47848ae2006-12-14 11:20:06811</p>
812</dd>
813<dt>
814--pickaxe-all
815</dt>
816<dd>
817<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37818 When <tt>-S</tt> finds a change, show all the changes in that
Junio C Hamano47848ae2006-12-14 11:20:06819 changeset, not just the files that contain the change
820 in &lt;string&gt;.
821</p>
822</dd>
823<dt>
824--pickaxe-regex
825</dt>
826<dd>
827<p>
828 Make the &lt;string&gt; not a plain string but an extended POSIX
829 regex to match.
830</p>
831</dd>
832<dt>
833-O&lt;orderfile&gt;
834</dt>
835<dd>
836<p>
837 Output the patch in the order specified in the
838 &lt;orderfile&gt;, which has one shell glob pattern per line.
839</p>
840</dd>
841<dt>
842-R
843</dt>
844<dd>
845<p>
846 Swap two inputs; that is, show differences from index or
847 on-disk file to tree contents.
848</p>
849</dd>
850<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44851--relative[=&lt;path&gt;]
852</dt>
853<dd>
854<p>
855 When run from a subdirectory of the project, it can be
856 told to exclude changes outside the directory and show
857 pathnames relative to it with this option. When you are
858 not in a subdirectory (e.g. in a bare repository), you
859 can name which subdirectory to make the output relative
860 to by giving a &lt;path&gt; as an argument.
861</p>
862</dd>
863<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22864-a
865</dt>
866<dt>
Junio C Hamano47848ae2006-12-14 11:20:06867--text
868</dt>
869<dd>
870<p>
871 Treat all files as text.
872</p>
873</dd>
874<dt>
Junio C Hamanofd468962007-02-14 23:45:04875--ignore-space-at-eol
876</dt>
877<dd>
878<p>
Junio C Hamano3a702342007-12-12 21:34:02879 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04880</p>
881</dd>
882<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22883-b
884</dt>
885<dt>
Junio C Hamano47848ae2006-12-14 11:20:06886--ignore-space-change
887</dt>
888<dd>
889<p>
Junio C Hamano3a702342007-12-12 21:34:02890 Ignore changes in amount of whitespace. This ignores whitespace
891 at line end, and considers all other sequences of one or
892 more whitespace characters to be equivalent.
Junio C Hamano47848ae2006-12-14 11:20:06893</p>
894</dd>
895<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22896-w
Junio C Hamano47848ae2006-12-14 11:20:06897</dt>
Junio C Hamano47848ae2006-12-14 11:20:06898<dt>
899--ignore-all-space
900</dt>
901<dd>
902<p>
Junio C Hamano3a702342007-12-12 21:34:02903 Ignore whitespace when comparing lines. This ignores
904 differences even if one line has whitespace where the other
Junio C Hamano47848ae2006-12-14 11:20:06905 line has none.
906</p>
907</dd>
908<dt>
Junio C Hamano1d40ee82009-01-07 10:14:16909--inter-hunk-context=&lt;lines&gt;
910</dt>
911<dd>
912<p>
913 Show the context between diff hunks, up to the specified number
914 of lines, thereby fusing hunks that are close to each other.
915</p>
916</dd>
917<dt>
Junio C Hamano48fd2f62007-03-19 02:02:30918--exit-code
919</dt>
920<dd>
921<p>
922 Make the program exit with codes similar to diff(1).
923 That is, it exits with 1 if there were differences and
924 0 means no differences.
925</p>
926</dd>
Junio C Hamano35e57552007-03-25 07:54:35927<dt>
928--quiet
929</dt>
930<dd>
931<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37932 Disable all output of the program. Implies <tt>--exit-code</tt>.
Junio C Hamano35e57552007-03-25 07:54:35933</p>
934</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40935<dt>
936--ext-diff
937</dt>
938<dd>
939<p>
940 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53941 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
942 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40943</p>
944</dd>
945<dt>
946--no-ext-diff
947</dt>
948<dd>
949<p>
950 Disallow external diff drivers.
951</p>
952</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33953<dt>
Junio C Hamanodfccbb02008-05-26 01:16:14954--ignore-submodules
955</dt>
956<dd>
957<p>
958 Ignore changes to submodules in the diff generation.
959</p>
960</dd>
961<dt>
Junio C Hamanoe27cbd22007-12-21 17:57:33962--src-prefix=&lt;prefix&gt;
963</dt>
964<dd>
965<p>
966 Show the given source prefix instead of "a/".
967</p>
968</dd>
969<dt>
970--dst-prefix=&lt;prefix&gt;
971</dt>
972<dd>
973<p>
974 Show the given destination prefix instead of "b/".
975</p>
976</dd>
977<dt>
978--no-prefix
979</dt>
980<dd>
981<p>
982 Do not show any source or destination prefix.
983</p>
984</dd>
Junio C Hamano0868a302008-07-22 09:20:44985</dl></div>
986<div class="para"><p>For more detailed explanation on these common options, see also
987<a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
988<div class="vlist"><dl>
Junio C Hamano47848ae2006-12-14 11:20:06989<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23990&lt;path&gt;&#8230;
991</dt>
992<dd>
993<p>
Junio C Hamano47848ae2006-12-14 11:20:06994 The &lt;paths&gt; parameters, when given, are used to limit
995 the diff to the named paths (you can give directory
996 names and get diff for all files under them).
Junio C Hamano1a4e8412005-12-27 08:17:23997</p>
998</dd>
Junio C Hamano0868a302008-07-22 09:20:44999</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:231000</div>
Junio C Hamano543f8d62009-07-29 08:35:211001<h2 id="_raw_output_format">Raw output format</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461002<div class="sectionbody">
Junio C Hamano543f8d62009-07-29 08:35:211003<div class="para"><p>The raw output format from "git-diff-index", "git-diff-tree",
Junio C Hamano0868a302008-07-22 09:20:441004"git-diff-files" and "git diff --raw" are very similar.</p></div>
1005<div class="para"><p>These commands all compare two sets of things; what is
1006compared differs:</p></div>
1007<div class="vlist"><dl>
Junio C Hamano7ae0ab22007-11-03 02:46:461008<dt>
1009git-diff-index &lt;tree-ish&gt;
1010</dt>
1011<dd>
1012<p>
1013 compares the &lt;tree-ish&gt; and the files on the filesystem.
1014</p>
1015</dd>
1016<dt>
1017git-diff-index --cached &lt;tree-ish&gt;
1018</dt>
1019<dd>
1020<p>
1021 compares the &lt;tree-ish&gt; and the index.
1022</p>
1023</dd>
1024<dt>
1025git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1026</dt>
1027<dd>
1028<p>
1029 compares the trees named by the two arguments.
1030</p>
1031</dd>
1032<dt>
1033git-diff-files [&lt;pattern&gt;&#8230;]
1034</dt>
1035<dd>
1036<p>
1037 compares the index and the files on the filesystem.
1038</p>
1039</dd>
Junio C Hamano0868a302008-07-22 09:20:441040</dl></div>
Junio C Hamano167b1382010-01-31 23:04:311041<div class="para"><p>The "git-diff-tree" command begins its output by printing the hash of
Junio C Hamano543f8d62009-07-29 08:35:211042what is being compared. After that, all the commands print one output
1043line per changed file.</p></div>
Junio C Hamano0868a302008-07-22 09:20:441044<div class="para"><p>An output line is formatted this way:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461045<div class="listingblock">
1046<div class="content">
1047<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1048copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1049rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1050create :000000 100644 0000000... 1234567... A file4
1051delete :100644 000000 1234567... 0000000... D file5
1052unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1053</div></div>
Junio C Hamano0868a302008-07-22 09:20:441054<div class="para"><p>That is, from the left to the right:</p></div>
1055<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461056<li>
1057<p>
1058a colon.
1059</p>
1060</li>
1061<li>
1062<p>
1063mode for "src"; 000000 if creation or unmerged.
1064</p>
1065</li>
1066<li>
1067<p>
1068a space.
1069</p>
1070</li>
1071<li>
1072<p>
1073mode for "dst"; 000000 if deletion or unmerged.
1074</p>
1075</li>
1076<li>
1077<p>
1078a space.
1079</p>
1080</li>
1081<li>
1082<p>
1083sha1 for "src"; 0{40} if creation or unmerged.
1084</p>
1085</li>
1086<li>
1087<p>
1088a space.
1089</p>
1090</li>
1091<li>
1092<p>
1093sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1094</p>
1095</li>
1096<li>
1097<p>
1098a space.
1099</p>
1100</li>
1101<li>
1102<p>
1103status, followed by optional "score" number.
1104</p>
1105</li>
1106<li>
1107<p>
1108a tab or a NUL when <em>-z</em> option is used.
1109</p>
1110</li>
1111<li>
1112<p>
1113path for "src"
1114</p>
1115</li>
1116<li>
1117<p>
1118a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1119</p>
1120</li>
1121<li>
1122<p>
1123path for "dst"; only exists for C or R.
1124</p>
1125</li>
1126<li>
1127<p>
1128an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1129</p>
1130</li>
Junio C Hamano0868a302008-07-22 09:20:441131</ol></div>
Junio C Hamanoaa17c7c2008-11-03 04:36:581132<div class="para"><p>Possible status letters are:</p></div>
1133<div class="ilist"><ul>
1134<li>
1135<p>
1136A: addition of a file
1137</p>
1138</li>
1139<li>
1140<p>
1141C: copy of a file into a new one
1142</p>
1143</li>
1144<li>
1145<p>
1146D: deletion of a file
1147</p>
1148</li>
1149<li>
1150<p>
1151M: modification of the contents or mode of a file
1152</p>
1153</li>
1154<li>
1155<p>
1156R: renaming of a file
1157</p>
1158</li>
1159<li>
1160<p>
1161T: change in the type of the file
1162</p>
1163</li>
1164<li>
1165<p>
1166U: file is unmerged (you must complete the merge before it can
1167be committed)
1168</p>
1169</li>
1170<li>
1171<p>
1172X: "unknown" change type (most probably a bug, please report it)
1173</p>
1174</li>
1175</ul></div>
Junio C Hamano54bf1e22008-12-20 06:30:111176<div class="para"><p>Status letters C and R are always followed by a score (denoting the
Junio C Hamanoaa17c7c2008-11-03 04:36:581177percentage of similarity between the source and target of the move or
1178copy), and are the only ones to be so.</p></div>
Junio C Hamano0868a302008-07-22 09:20:441179<div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1180and it is out of sync with the index.</p></div>
1181<div class="para"><p>Example:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461182<div class="listingblock">
1183<div class="content">
1184<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1185</div></div>
Junio C Hamano0868a302008-07-22 09:20:441186<div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
Junio C Hamano7ae0ab22007-11-03 02:46:461187in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
Junio C Hamano0868a302008-07-22 09:20:441188respectively.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461189</div>
Junio C Hamano0868a302008-07-22 09:20:441190<h2 id="_diff_format_for_merges">diff format for merges</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461191<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441192<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
Junio C Hamano7ae0ab22007-11-03 02:46:461193can take <em>-c</em> or <em>--cc</em> option
1194to generate diff output also for merge commits. The output differs
Junio C Hamano0868a302008-07-22 09:20:441195from the format described above in the following way:</p></div>
1196<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461197<li>
1198<p>
1199there is a colon for each parent
1200</p>
1201</li>
1202<li>
1203<p>
1204there are more "src" modes and "src" sha1
1205</p>
1206</li>
1207<li>
1208<p>
1209status is concatenated status characters for each parent
1210</p>
1211</li>
1212<li>
1213<p>
1214no optional "score" number
1215</p>
1216</li>
1217<li>
1218<p>
1219single path, only for "dst"
1220</p>
1221</li>
Junio C Hamano0868a302008-07-22 09:20:441222</ol></div>
1223<div class="para"><p>Example:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461224<div class="listingblock">
1225<div class="content">
1226<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1227</div></div>
Junio C Hamano0868a302008-07-22 09:20:441228<div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1229all parents.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461230</div>
Junio C Hamano0868a302008-07-22 09:20:441231<h2 id="_generating_patches_with_p">Generating patches with -p</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461232<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441233<div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491234with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1235"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461236do not produce the output described above; instead they produce a
1237patch file. You can customize the creation of such patches via the
Junio C Hamano0868a302008-07-22 09:20:441238GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1239<div class="para"><p>What the -p option produces is slightly different from the traditional
1240diff format.</p></div>
1241<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461242<li>
1243<p>
1244It is preceded with a "git diff" header, that looks like
1245 this:
1246</p>
1247<div class="literalblock">
1248<div class="content">
1249<pre><tt>diff --git a/file1 b/file2</tt></pre>
1250</div></div>
Junio C Hamano0868a302008-07-22 09:20:441251<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:461252involved. Especially, even for a creation or a deletion,
Junio C Hamanoe1b26832009-11-15 10:02:561253<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:441254<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:461255name of the source file of the rename/copy and the name of
Junio C Hamano0868a302008-07-22 09:20:441256the file that rename/copy produces, respectively.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461257</li>
1258<li>
1259<p>
1260It is followed by one or more extended header lines:
1261</p>
1262<div class="literalblock">
1263<div class="content">
1264<pre><tt>old mode &lt;mode&gt;
1265new mode &lt;mode&gt;
1266deleted file mode &lt;mode&gt;
1267new file mode &lt;mode&gt;
1268copy from &lt;path&gt;
1269copy to &lt;path&gt;
1270rename from &lt;path&gt;
1271rename to &lt;path&gt;
1272similarity index &lt;number&gt;
1273dissimilarity index &lt;number&gt;
1274index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1275</div></div>
1276</li>
1277<li>
1278<p>
1279TAB, LF, double quote and backslash characters in pathnames
1280 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1281 If there is need for such substitution then the whole
1282 pathname is put in double quotes.
1283</p>
1284</li>
Junio C Hamano0868a302008-07-22 09:20:441285</ol></div>
1286<div class="para"><p>The similarity index is the percentage of unchanged lines, and
Junio C Hamano7ae0ab22007-11-03 02:46:461287the dissimilarity index is the percentage of changed lines. It
1288is a rounded down integer, followed by a percent sign. The
1289similarity index value of 100% is thus reserved for two equal
1290files, while 100% dissimilarity means that no line from the old
Junio C Hamano0868a302008-07-22 09:20:441291file made it into the new one.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461292</div>
Junio C Hamano0868a302008-07-22 09:20:441293<h2 id="_combined_diff_format">combined diff format</h2>
Junio C Hamano7ae0ab22007-11-03 02:46:461294<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441295<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:491296<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
Junio C Hamano31667362010-03-25 00:38:531297with "git log -p", this is the default format; you can force showing
1298full diff with the <em>-m</em> option.
Junio C Hamano0868a302008-07-22 09:20:441299A <em>combined diff</em> format looks like this:</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461300<div class="listingblock">
1301<div class="content">
1302<pre><tt>diff --combined describe.c
1303index fabadb8,cc95eb0..4866510
1304--- a/describe.c
1305+++ b/describe.c
1306@@@ -98,20 -98,12 +98,20 @@@
1307 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1308 }
1309
1310- static void describe(char *arg)
1311 -static void describe(struct commit *cmit, int last_one)
1312++static void describe(char *arg, int last_one)
1313 {
1314 + unsigned char sha1[20];
1315 + struct commit *cmit;
1316 struct commit_list *list;
1317 static int initialized = 0;
1318 struct commit_name *n;
1319
1320 + if (get_sha1(arg, sha1) &lt; 0)
1321 + usage(describe_usage);
1322 + cmit = lookup_commit_reference(sha1);
1323 + if (!cmit)
1324 + usage(describe_usage);
1325 +
1326 if (!initialized) {
1327 initialized = 1;
1328 for_each_ref(get_name);</tt></pre>
1329</div></div>
Junio C Hamano0868a302008-07-22 09:20:441330<div class="olist"><ol>
Junio C Hamano7ae0ab22007-11-03 02:46:461331<li>
1332<p>
1333It is preceded with a "git diff" header, that looks like
1334 this (when <em>-c</em> option is used):
1335</p>
1336<div class="literalblock">
1337<div class="content">
1338<pre><tt>diff --combined file</tt></pre>
1339</div></div>
Junio C Hamano0868a302008-07-22 09:20:441340<div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461341<div class="literalblock">
1342<div class="content">
Junio C Hamano0868a302008-07-22 09:20:441343<pre><tt>diff --cc file</tt></pre>
Junio C Hamano7ae0ab22007-11-03 02:46:461344</div></div>
1345</li>
1346<li>
1347<p>
1348It is followed by one or more extended header lines
1349 (this example shows a merge with two parents):
1350</p>
1351<div class="literalblock">
1352<div class="content">
1353<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1354mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1355new file mode &lt;mode&gt;
1356deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1357</div></div>
Junio C Hamano0868a302008-07-22 09:20:441358<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:461359the &lt;mode&gt; is different from the rest. Extended headers with
1360information about detected contents movement (renames and
1361copying detection) are designed to work with diff of two
Junio C Hamano0868a302008-07-22 09:20:441362&lt;tree-ish&gt; and are not used by combined diff format.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461363</li>
1364<li>
1365<p>
1366It is followed by two-line from-file/to-file header
1367</p>
1368<div class="literalblock">
1369<div class="content">
1370<pre><tt>--- a/file
1371+++ b/file</tt></pre>
1372</div></div>
Junio C Hamano0868a302008-07-22 09:20:441373<div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
Junio C Hamano7ae0ab22007-11-03 02:46:461374format, <tt>/dev/null</tt> is used to signal created or deleted
Junio C Hamano0868a302008-07-22 09:20:441375files.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461376</li>
1377<li>
1378<p>
1379Chunk header format is modified to prevent people from
1380 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1381 was created for review of merge commit changes, and was not
1382 meant for apply. The change is similar to the change in the
1383 extended <em>index</em> header:
1384</p>
1385<div class="literalblock">
1386<div class="content">
1387<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1388</div></div>
Junio C Hamano0868a302008-07-22 09:20:441389<div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1390header for combined diff format.</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461391</li>
Junio C Hamano0868a302008-07-22 09:20:441392</ol></div>
1393<div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
Junio C Hamano7ae0ab22007-11-03 02:46:461394files A and B with a single column that has <tt>-</tt> (minus &#8212;
1395appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
1396added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
1397compares two or more files file1, file2,&#8230; with one file X, and
1398shows how X differs from each of fileN. One column for each of
1399fileN is prepended to the output line to note how X's line is
Junio C Hamano0868a302008-07-22 09:20:441400different from it.</p></div>
1401<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:461402fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamano54bf1e22008-12-20 06:30:111403in the column N means that the line appears in the result,
Junio C Hamano7ae0ab22007-11-03 02:46:461404and fileN does not have that line (in other words, the line was
Junio C Hamano0868a302008-07-22 09:20:441405added, from the point of view of that parent).</p></div>
1406<div class="para"><p>In the above example output, the function signature was changed
Junio C Hamano7ae0ab22007-11-03 02:46:461407from both files (hence two <tt>-</tt> removals from both file1 and
Junio C Hamano4604fe52008-09-19 06:37:101408file2, plus <tt>++</tt> to mean one line that was added does not appear
Junio C Hamano54bf1e22008-12-20 06:30:111409in either file1 nor file2). Also eight other lines are the same
1410from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
Junio C Hamano0868a302008-07-22 09:20:441411<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:461412merge commit with the merge result (i.e. file1..fileN are the
1413parents). When shown by <tt>git diff-files -c</tt>, it compares the
1414two unresolved merge parents with the working tree file
1415(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
Junio C Hamano0868a302008-07-22 09:20:441416"their version").</p></div>
Junio C Hamano7ae0ab22007-11-03 02:46:461417</div>
Junio C Hamano0868a302008-07-22 09:20:441418<h2 id="_other_diff_formats">other diff formats</h2>
Junio C Hamano3a702342007-12-12 21:34:021419<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441420<div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
Junio C Hamano3a702342007-12-12 21:34:021421copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1422output. These options can be combined with other options, such as
Junio C Hamano0868a302008-07-22 09:20:441423<tt>-p</tt>, and are meant for human consumption.</p></div>
1424<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:021425formats the pathnames compactly by combining common prefix and suffix of
1426the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
Junio C Hamano0868a302008-07-22 09:20:441427<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021428<div class="listingblock">
1429<div class="content">
1430<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1431</div></div>
Junio C Hamano0868a302008-07-22 09:20:441432<div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
Junio C Hamano3a702342007-12-12 21:34:021433for easier machine consumption. An entry in <tt>--numstat</tt> output looks
Junio C Hamano0868a302008-07-22 09:20:441434like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021435<div class="listingblock">
1436<div class="content">
1437<pre><tt>1 2 README
14383 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1439</div></div>
Junio C Hamano0868a302008-07-22 09:20:441440<div class="para"><p>That is, from left to right:</p></div>
1441<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021442<li>
1443<p>
1444the number of added lines;
1445</p>
1446</li>
1447<li>
1448<p>
1449a tab;
1450</p>
1451</li>
1452<li>
1453<p>
1454the number of deleted lines;
1455</p>
1456</li>
1457<li>
1458<p>
1459a tab;
1460</p>
1461</li>
1462<li>
1463<p>
1464pathname (possibly with rename/copy information);
1465</p>
1466</li>
1467<li>
1468<p>
1469a newline.
1470</p>
1471</li>
Junio C Hamano0868a302008-07-22 09:20:441472</ol></div>
1473<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:021474<div class="listingblock">
1475<div class="content">
1476<pre><tt>1 2 README NUL
14773 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1478</div></div>
Junio C Hamano0868a302008-07-22 09:20:441479<div class="para"><p>That is:</p></div>
1480<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021481<li>
1482<p>
1483the number of added lines;
1484</p>
1485</li>
1486<li>
1487<p>
1488a tab;
1489</p>
1490</li>
1491<li>
1492<p>
1493the number of deleted lines;
1494</p>
1495</li>
1496<li>
1497<p>
1498a tab;
1499</p>
1500</li>
1501<li>
1502<p>
1503a NUL (only exists if renamed/copied);
1504</p>
1505</li>
1506<li>
1507<p>
1508pathname in preimage;
1509</p>
1510</li>
1511<li>
1512<p>
1513a NUL (only exists if renamed/copied);
1514</p>
1515</li>
1516<li>
1517<p>
1518pathname in postimage (only exists if renamed/copied);
1519</p>
1520</li>
1521<li>
1522<p>
1523a NUL.
1524</p>
1525</li>
Junio C Hamano0868a302008-07-22 09:20:441526</ol></div>
1527<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:021528scripts that read the output to tell if the current record being read is
1529a single-path record or a rename/copy record without reading ahead.
1530After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
Junio C Hamano0868a302008-07-22 09:20:441531the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
Junio C Hamano3a702342007-12-12 21:34:021532</div>
Junio C Hamano0868a302008-07-22 09:20:441533<h2 id="_examples">EXAMPLES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231534<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441535<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:231536<dt>
1537Various ways to check your working tree
1538</dt>
1539<dd>
1540<div class="listingblock">
1541<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011542<pre><tt>$ git diff <b>(1)</b>
Junio C Hamano47848ae2006-12-14 11:20:061543$ git diff --cached <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011544$ git diff HEAD <b>(3)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231545</div></div>
Junio C Hamano0868a302008-07-22 09:20:441546<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011547<li>
1548<p>
Junio C Hamano092f5f02007-08-02 07:23:381549Changes in the working tree not yet staged for the next commit.
Junio C Hamanoc8d88c22006-04-29 07:02:011550</p>
1551</li>
1552<li>
1553<p>
Junio C Hamano092f5f02007-08-02 07:23:381554Changes between the index and your last commit; what you
Junio C Hamanoc8d88c22006-04-29 07:02:011555would be committing if you run "git commit" without "-a" option.
1556</p>
1557</li>
1558<li>
1559<p>
Junio C Hamano092f5f02007-08-02 07:23:381560Changes in the working tree since your last commit; what you
Junio C Hamanoc8d88c22006-04-29 07:02:011561would be committing if you run "git commit -a"
1562</p>
1563</li>
Junio C Hamano0868a302008-07-22 09:20:441564</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231565</dd>
1566<dt>
1567Comparing with arbitrary commits
1568</dt>
1569<dd>
1570<div class="listingblock">
1571<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011572<pre><tt>$ git diff test <b>(1)</b>
1573$ git diff HEAD -- ./test <b>(2)</b>
1574$ git diff HEAD^ HEAD <b>(3)</b></tt></pre>
1575</div></div>
Junio C Hamano0868a302008-07-22 09:20:441576<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011577<li>
1578<p>
Junio C Hamano092f5f02007-08-02 07:23:381579Instead of using the tip of the current branch, compare with the
Junio C Hamano1a4e8412005-12-27 08:17:231580tip of "test" branch.
Junio C Hamanoc8d88c22006-04-29 07:02:011581</p>
1582</li>
1583<li>
1584<p>
Junio C Hamano092f5f02007-08-02 07:23:381585Instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:581586the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:231587file "test".
Junio C Hamanoc8d88c22006-04-29 07:02:011588</p>
1589</li>
1590<li>
1591<p>
Junio C Hamano092f5f02007-08-02 07:23:381592Compare the version before the last commit and the last commit.
Junio C Hamanoc8d88c22006-04-29 07:02:011593</p>
1594</li>
Junio C Hamano0868a302008-07-22 09:20:441595</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231596</dd>
1597<dt>
Junio C Hamanoc435b1c2007-08-28 06:25:351598Comparing branches
1599</dt>
1600<dd>
1601<div class="listingblock">
1602<div class="content">
1603<pre><tt>$ git diff topic master <b>(1)</b>
1604$ git diff topic..master <b>(2)</b>
1605$ git diff topic...master <b>(3)</b></tt></pre>
1606</div></div>
Junio C Hamano0868a302008-07-22 09:20:441607<div class="colist"><ol>
Junio C Hamanoc435b1c2007-08-28 06:25:351608<li>
1609<p>
1610Changes between the tips of the topic and the master branches.
1611</p>
1612</li>
1613<li>
1614<p>
1615Same as above.
1616</p>
1617</li>
1618<li>
1619<p>
Junio C Hamano764a6672007-10-23 01:23:311620Changes that occurred on the master branch since when the topic
Junio C Hamanoc435b1c2007-08-28 06:25:351621branch was started off it.
1622</p>
1623</li>
Junio C Hamano0868a302008-07-22 09:20:441624</ol></div>
Junio C Hamanoc435b1c2007-08-28 06:25:351625</dd>
1626<dt>
Junio C Hamano1a4e8412005-12-27 08:17:231627Limiting the diff output
1628</dt>
1629<dd>
1630<div class="listingblock">
1631<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011632<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>
Junio C Hamanobdeff822007-07-30 09:07:171633$ git diff --name-status <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:011634$ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>
1635</div></div>
Junio C Hamano0868a302008-07-22 09:20:441636<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011637<li>
1638<p>
Junio C Hamano092f5f02007-08-02 07:23:381639Show only modification, rename and copy, but not addition
Junio C Hamano1a4e8412005-12-27 08:17:231640nor deletion.
Junio C Hamanoc8d88c22006-04-29 07:02:011641</p>
1642</li>
1643<li>
1644<p>
Junio C Hamano092f5f02007-08-02 07:23:381645Show only names and the nature of change, but not actual
Junio C Hamanobdeff822007-07-30 09:07:171646diff output.
Junio C Hamanoc8d88c22006-04-29 07:02:011647</p>
1648</li>
1649<li>
1650<p>
Junio C Hamano092f5f02007-08-02 07:23:381651Limit diff output to named subtrees.
Junio C Hamanoc8d88c22006-04-29 07:02:011652</p>
1653</li>
Junio C Hamano0868a302008-07-22 09:20:441654</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231655</dd>
1656<dt>
1657Munging the diff output
1658</dt>
1659<dd>
1660<div class="listingblock">
1661<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:011662<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>
1663$ git diff -R <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231664</div></div>
Junio C Hamano0868a302008-07-22 09:20:441665<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011666<li>
1667<p>
Junio C Hamano092f5f02007-08-02 07:23:381668Spend extra cycles to find renames, copies and complete
Junio C Hamanoc8d88c22006-04-29 07:02:011669rewrites (very expensive).
1670</p>
1671</li>
1672<li>
1673<p>
Junio C Hamano092f5f02007-08-02 07:23:381674Output diff in reverse.
Junio C Hamanoc8d88c22006-04-29 07:02:011675</p>
1676</li>
Junio C Hamano0868a302008-07-22 09:20:441677</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231678</dd>
Junio C Hamano0868a302008-07-22 09:20:441679</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:231680</div>
Junio C Hamanoa9701f02010-01-21 00:42:161681<h2 id="_see_also">SEE ALSO</h2>
1682<div class="sectionbody">
1683<div class="vlist"><dl>
1684<dt>
1685<a href="git-difftool.html">git-difftool(1)</a>
1686</dt>
1687<dd>
1688<p>
1689 Show changes using common diff tools
1690</p>
1691</dd>
1692</dl></div>
1693</div>
Junio C Hamano0868a302008-07-22 09:20:441694<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231695<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441696<div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231697</div>
Junio C Hamano0868a302008-07-22 09:20:441698<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231699<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441700<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:231701</div>
Junio C Hamano0868a302008-07-22 09:20:441702<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231703<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441704<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231705</div>
1706<div id="footer">
1707<div id="footer-text">
Junio C Hamanocc7636a2010-05-21 14:57:531708Last updated 2010-05-21 14:57:17 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231709</div>
1710</div>
1711</body>
1712</html>