blob: bb0816db1c09d3e1ee403a66c940fac34e1fdf3f [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 Hamano01078922006-03-10 00:31:476<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff -
Junio C Hamano01078922006-03-10 00:31:47269 Show changes between commits, commit and working tree, etc
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano7d23f5e2006-12-16 07:44:04275<p><em>git-diff</em> [ --diff-options ] &lt;tree-ish&gt;{0,2} [--] [&lt;path&gt;&#8230;]</p>
Junio C Hamano1a4e8412005-12-27 08:17:23276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
Junio C Hamano51c2ab02006-07-09 20:38:54279<p>Show changes between two trees, a tree and the working tree, a
Junio C Hamano47848ae2006-12-14 11:20:06280tree and the index file, or the index file and the working tree.</p>
281<dl>
282<dt>
283<em>git-diff</em> [--options] [--] [&lt;path&gt;&#8230;]
284</dt>
285<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23286<p>
Junio C Hamano47848ae2006-12-14 11:20:06287 This form is to view the changes you made relative to
288 the index (staging area for the next commit). In other
289 words, the differences are what you _could_ tell git to
290 further add to the index but you still haven't. You can
291 stage these changes by using <a href="git-add.html">git-add(1)</a>.
Junio C Hamano1a4e8412005-12-27 08:17:23292</p>
Junio C Hamano47848ae2006-12-14 11:20:06293</dd>
294<dt>
295<em>git-diff</em> [--options] --cached [&lt;commit&gt;] [--] [&lt;path&gt;&#8230;]
296</dt>
297<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23298<p>
Junio C Hamano47848ae2006-12-14 11:20:06299 This form is to view the changes you staged for the next
300 commit relative to the named &lt;tree-ish&gt;. Typically you
301 would want comparison with the latest commit, so if you
302 do not give &lt;commit&gt;, it defaults to HEAD.
Junio C Hamano1a4e8412005-12-27 08:17:23303</p>
Junio C Hamano47848ae2006-12-14 11:20:06304</dd>
305<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04306<em>git-diff</em> [--options] &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06307</dt>
308<dd>
Junio C Hamano1a4e8412005-12-27 08:17:23309<p>
Junio C Hamano47848ae2006-12-14 11:20:06310 This form is to view the changes you have in your
311 working tree relative to the named &lt;commit&gt;. You can
312 use HEAD to compare it with the latest commit, or a
313 branch name to compare with the tip of a different
314 branch.
Junio C Hamano1a4e8412005-12-27 08:17:23315</p>
Junio C Hamano47848ae2006-12-14 11:20:06316</dd>
317<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04318<em>git-diff</em> [--options] &lt;commit&gt; &lt;commit&gt; [--] [&lt;path&gt;&#8230;]
Junio C Hamano47848ae2006-12-14 11:20:06319</dt>
320<dd>
321<p>
322 This form is to view the changes between two &lt;commit&gt;,
323 for example, tips of two branches.
324</p>
325</dd>
326</dl>
327<p>Just in case if you are doing something exotic, it should be
328noted that all of the &lt;commit&gt; in the above description can be
329any &lt;tree-ish&gt;.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23330</div>
331<h2>OPTIONS</h2>
332<div class="sectionbody">
333<dl>
334<dt>
Junio C Hamano47848ae2006-12-14 11:20:06335-p
Junio C Hamano1a4e8412005-12-27 08:17:23336</dt>
337<dd>
338<p>
Junio C Hamano47848ae2006-12-14 11:20:06339 Generate patch (see section on generating patches)
Junio C Hamano1a4e8412005-12-27 08:17:23340</p>
341</dd>
342<dt>
Junio C Hamano47848ae2006-12-14 11:20:06343-u
344</dt>
345<dd>
346<p>
347 Synonym for "-p".
348</p>
349</dd>
350<dt>
351--raw
352</dt>
353<dd>
354<p>
355 Generate the raw format.
356</p>
357</dd>
358<dt>
359--patch-with-raw
360</dt>
361<dd>
362<p>
363 Synonym for "-p --raw".
364</p>
365</dd>
366<dt>
367--stat[=width[,name-width]]
368</dt>
369<dd>
370<p>
371 Generate a diffstat. You can override the default
372 output width for 80-column terminal by "--stat=width".
373 The width of the filename part can be controlled by
374 giving another width to it separated by a comma.
375</p>
376</dd>
377<dt>
378--numstat
379</dt>
380<dd>
381<p>
382 Similar to --stat, but shows number of added and
383 deleted lines in decimal notation and pathname without
384 abbreviation, to make it more machine friendly.
385</p>
386</dd>
387<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04388--shortstat
389</dt>
390<dd>
391<p>
392 Output only the last line of the --stat format containing total
393 number of modified files, as well as number of added and deleted
394 lines.
395</p>
396</dd>
397<dt>
Junio C Hamano47848ae2006-12-14 11:20:06398--summary
399</dt>
400<dd>
401<p>
402 Output a condensed summary of extended header information
403 such as creations, renames and mode changes.
404</p>
405</dd>
406<dt>
407--patch-with-stat
408</dt>
409<dd>
410<p>
411 Synonym for "-p --stat".
412</p>
413</dd>
414<dt>
415-z
416</dt>
417<dd>
418<p>
419 \0 line termination on output
420</p>
421</dd>
422<dt>
423--name-only
424</dt>
425<dd>
426<p>
427 Show only names of changed files.
428</p>
429</dd>
430<dt>
431--name-status
432</dt>
433<dd>
434<p>
435 Show only names and status of changed files.
436</p>
437</dd>
438<dt>
439--color
440</dt>
441<dd>
442<p>
443 Show colored diff.
444</p>
445</dd>
446<dt>
447--no-color
448</dt>
449<dd>
450<p>
451 Turn off colored diff, even when the configuration file
452 gives the default to color output.
453</p>
454</dd>
455<dt>
456--color-words
457</dt>
458<dd>
459<p>
460 Show colored word diff, i.e. color words which have changed.
461</p>
462</dd>
463<dt>
464--no-renames
465</dt>
466<dd>
467<p>
468 Turn off rename detection, even when the configuration
469 file gives the default to do so.
470</p>
471</dd>
472<dt>
473--full-index
474</dt>
475<dd>
476<p>
477 Instead of the first handful characters, show full
478 object name of pre- and post-image blob on the "index"
479 line when generating a patch format output.
480</p>
481</dd>
482<dt>
483--binary
484</dt>
485<dd>
486<p>
487 In addition to --full-index, output "binary diff" that
488 can be applied with "git apply".
489</p>
490</dd>
491<dt>
492--abbrev[=&lt;n&gt;]
493</dt>
494<dd>
495<p>
496 Instead of showing the full 40-byte hexadecimal object
497 name in diff-raw format output and diff-tree header
498 lines, show only handful hexdigits prefix. This is
499 independent of --full-index option above, which controls
500 the diff-patch output format. Non default number of
501 digits can be specified with --abbrev=&lt;n&gt;.
502</p>
503</dd>
504<dt>
505-B
506</dt>
507<dd>
508<p>
509 Break complete rewrite changes into pairs of delete and create.
510</p>
511</dd>
512<dt>
513-M
514</dt>
515<dd>
516<p>
517 Detect renames.
518</p>
519</dd>
520<dt>
521-C
522</dt>
523<dd>
524<p>
525 Detect copies as well as renames.
526</p>
527</dd>
528<dt>
529--diff-filter=[ACDMRTUXB*]
530</dt>
531<dd>
532<p>
533 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
534 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
535 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
536 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
537 Any combination of the filter characters may be used.
538 When <tt>*</tt> (All-or-none) is added to the combination, all
539 paths are selected if there is any file that matches
540 other criteria in the comparison; if there is no file
541 that matches other criteria, nothing is selected.
542</p>
543</dd>
544<dt>
545--find-copies-harder
546</dt>
547<dd>
548<p>
549 For performance reasons, by default, -C option finds copies only
550 if the original file of the copy was modified in the same
551 changeset. This flag makes the command
552 inspect unmodified files as candidates for the source of
553 copy. This is a very expensive operation for large
554 projects, so use it with caution.
555</p>
556</dd>
557<dt>
558-l&lt;num&gt;
559</dt>
560<dd>
561<p>
562 -M and -C options require O(n^2) processing time where n
563 is the number of potential rename/copy targets. This
564 option prevents rename/copy detection from running if
565 the number of rename/copy targets exceeds the specified
566 number.
567</p>
568</dd>
569<dt>
570-S&lt;string&gt;
571</dt>
572<dd>
573<p>
574 Look for differences that contain the change in &lt;string&gt;.
575</p>
576</dd>
577<dt>
578--pickaxe-all
579</dt>
580<dd>
581<p>
582 When -S finds a change, show all the changes in that
583 changeset, not just the files that contain the change
584 in &lt;string&gt;.
585</p>
586</dd>
587<dt>
588--pickaxe-regex
589</dt>
590<dd>
591<p>
592 Make the &lt;string&gt; not a plain string but an extended POSIX
593 regex to match.
594</p>
595</dd>
596<dt>
597-O&lt;orderfile&gt;
598</dt>
599<dd>
600<p>
601 Output the patch in the order specified in the
602 &lt;orderfile&gt;, which has one shell glob pattern per line.
603</p>
604</dd>
605<dt>
606-R
607</dt>
608<dd>
609<p>
610 Swap two inputs; that is, show differences from index or
611 on-disk file to tree contents.
612</p>
613</dd>
614<dt>
615--text
616</dt>
617<dd>
618<p>
619 Treat all files as text.
620</p>
621</dd>
622<dt>
623-a
624</dt>
625<dd>
626<p>
627 Shorthand for "--text".
628</p>
629</dd>
630<dt>
631--ignore-space-change
632</dt>
633<dd>
634<p>
635 Ignore changes in amount of white space. This ignores white
636 space at line end, and consider all other sequences of one or
637 more white space characters to be equivalent.
638</p>
639</dd>
640<dt>
641-b
642</dt>
643<dd>
644<p>
645 Shorthand for "--ignore-space-change".
646</p>
647</dd>
648<dt>
649--ignore-all-space
650</dt>
651<dd>
652<p>
653 Ignore white space when comparing lines. This ignores
654 difference even if one line has white space where the other
655 line has none.
656</p>
657</dd>
658<dt>
659-w
660</dt>
661<dd>
662<p>
663 Shorthand for "--ignore-all-space".
664</p>
665</dd>
666</dl>
667<p>For more detailed explanation on these common options, see also
668<a href="diffcore.html">diffcore documentation</a>.</p>
669<dl>
670<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23671&lt;path&gt;&#8230;
672</dt>
673<dd>
674<p>
Junio C Hamano47848ae2006-12-14 11:20:06675 The &lt;paths&gt; parameters, when given, are used to limit
676 the diff to the named paths (you can give directory
677 names and get diff for all files under them).
Junio C Hamano1a4e8412005-12-27 08:17:23678</p>
679</dd>
680</dl>
681</div>
682<h2>EXAMPLES</h2>
683<div class="sectionbody">
684<dl>
685<dt>
686Various ways to check your working tree
687</dt>
688<dd>
689<div class="listingblock">
690<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01691<pre><tt>$ git diff <b>(1)</b>
Junio C Hamano47848ae2006-12-14 11:20:06692$ git diff --cached <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01693$ git diff HEAD <b>(3)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23694</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01695<ol>
696<li>
697<p>
Junio C Hamano47848ae2006-12-14 11:20:06698changes in the working tree not yet staged for the next commit.
Junio C Hamanoc8d88c22006-04-29 07:02:01699</p>
700</li>
701<li>
702<p>
703changes between the index and your last commit; what you
704would be committing if you run "git commit" without "-a" option.
705</p>
706</li>
707<li>
708<p>
709changes in the working tree since your last commit; what you
710would be committing if you run "git commit -a"
711</p>
712</li>
713</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23714</dd>
715<dt>
716Comparing with arbitrary commits
717</dt>
718<dd>
719<div class="listingblock">
720<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01721<pre><tt>$ git diff test <b>(1)</b>
722$ git diff HEAD -- ./test <b>(2)</b>
723$ git diff HEAD^ HEAD <b>(3)</b></tt></pre>
724</div></div>
725<ol>
726<li>
727<p>
728instead of using the tip of the current branch, compare with the
Junio C Hamano1a4e8412005-12-27 08:17:23729tip of "test" branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01730</p>
731</li>
732<li>
733<p>
734instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:58735the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:23736file "test".
Junio C Hamanoc8d88c22006-04-29 07:02:01737</p>
738</li>
739<li>
740<p>
741compare the version before the last commit and the last commit.
742</p>
743</li>
744</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23745</dd>
746<dt>
747Limiting the diff output
748</dt>
749<dd>
750<div class="listingblock">
751<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01752<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>
753$ git diff --name-status -r <b>(2)</b>
754$ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>
755</div></div>
756<ol>
757<li>
758<p>
759show only modification, rename and copy, but not addition
Junio C Hamano1a4e8412005-12-27 08:17:23760nor deletion.
Junio C Hamanoc8d88c22006-04-29 07:02:01761</p>
762</li>
763<li>
764<p>
765show only names and the nature of change, but not actual
Junio C Hamano1a4e8412005-12-27 08:17:23766diff output. --name-status disables usual patch generation
Junio C Hamano341071d2006-06-04 07:24:48767which in turn also disables recursive behavior, so without -r
Junio C Hamano1a4e8412005-12-27 08:17:23768you would only see the directory name if there is a change in a
769file in a subdirectory.
Junio C Hamanoc8d88c22006-04-29 07:02:01770</p>
771</li>
772<li>
773<p>
774limit diff output to named subtrees.
775</p>
776</li>
777</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23778</dd>
779<dt>
780Munging the diff output
781</dt>
782<dd>
783<div class="listingblock">
784<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01785<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>
786$ git diff -R <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23787</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01788<ol>
789<li>
790<p>
791spend extra cycles to find renames, copies and complete
792rewrites (very expensive).
793</p>
794</li>
795<li>
796<p>
797output diff in reverse.
798</p>
799</li>
800</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23801</dd>
802</dl>
803</div>
804<h2>Author</h2>
805<div class="sectionbody">
806<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
807</div>
808<h2>Documentation</h2>
809<div class="sectionbody">
810<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
811</div>
812<h2>GIT</h2>
813<div class="sectionbody">
814<p>Part of the <a href="git.html">git(7)</a> suite</p>
815</div>
816<div id="footer">
817<div id="footer-text">
Junio C Hamano7d23f5e2006-12-16 07:44:04818Last updated 16-Dec-2006 07:43:51 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23819</div>
820</div>
821</body>
822</html>