blob: 8fb0e467624846557ac6f35262a5de572c3b9525 [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 Hamano4bf6dca2006-12-21 02:25:57275<p><em>git-diff</em> [ --diff-options ] &lt;commit&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
Junio C Hamano4bf6dca2006-12-21 02:25:57300 commit relative to the named &lt;commit&gt;. Typically you
Junio C Hamano47848ae2006-12-14 11:20:06301 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
Junio C Hamanod793de52006-12-26 09:11:43384 abbreviation, to make it more machine friendly. For
385 binary files, outputs two <tt>-</tt> instead of saying
386 <tt>0 0</tt>.
Junio C Hamano47848ae2006-12-14 11:20:06387</p>
388</dd>
389<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04390--shortstat
391</dt>
392<dd>
393<p>
394 Output only the last line of the --stat format containing total
395 number of modified files, as well as number of added and deleted
396 lines.
397</p>
398</dd>
399<dt>
Junio C Hamano47848ae2006-12-14 11:20:06400--summary
401</dt>
402<dd>
403<p>
404 Output a condensed summary of extended header information
405 such as creations, renames and mode changes.
406</p>
407</dd>
408<dt>
409--patch-with-stat
410</dt>
411<dd>
412<p>
413 Synonym for "-p --stat".
414</p>
415</dd>
416<dt>
417-z
418</dt>
419<dd>
420<p>
421 \0 line termination on output
422</p>
423</dd>
424<dt>
425--name-only
426</dt>
427<dd>
428<p>
429 Show only names of changed files.
430</p>
431</dd>
432<dt>
433--name-status
434</dt>
435<dd>
436<p>
437 Show only names and status of changed files.
438</p>
439</dd>
440<dt>
441--color
442</dt>
443<dd>
444<p>
445 Show colored diff.
446</p>
447</dd>
448<dt>
449--no-color
450</dt>
451<dd>
452<p>
453 Turn off colored diff, even when the configuration file
454 gives the default to color output.
455</p>
456</dd>
457<dt>
458--color-words
459</dt>
460<dd>
461<p>
462 Show colored word diff, i.e. color words which have changed.
463</p>
464</dd>
465<dt>
466--no-renames
467</dt>
468<dd>
469<p>
470 Turn off rename detection, even when the configuration
471 file gives the default to do so.
472</p>
473</dd>
474<dt>
475--full-index
476</dt>
477<dd>
478<p>
479 Instead of the first handful characters, show full
480 object name of pre- and post-image blob on the "index"
481 line when generating a patch format output.
482</p>
483</dd>
484<dt>
485--binary
486</dt>
487<dd>
488<p>
489 In addition to --full-index, output "binary diff" that
490 can be applied with "git apply".
491</p>
492</dd>
493<dt>
494--abbrev[=&lt;n&gt;]
495</dt>
496<dd>
497<p>
498 Instead of showing the full 40-byte hexadecimal object
499 name in diff-raw format output and diff-tree header
500 lines, show only handful hexdigits prefix. This is
501 independent of --full-index option above, which controls
502 the diff-patch output format. Non default number of
503 digits can be specified with --abbrev=&lt;n&gt;.
504</p>
505</dd>
506<dt>
507-B
508</dt>
509<dd>
510<p>
511 Break complete rewrite changes into pairs of delete and create.
512</p>
513</dd>
514<dt>
515-M
516</dt>
517<dd>
518<p>
519 Detect renames.
520</p>
521</dd>
522<dt>
523-C
524</dt>
525<dd>
526<p>
527 Detect copies as well as renames.
528</p>
529</dd>
530<dt>
531--diff-filter=[ACDMRTUXB*]
532</dt>
533<dd>
534<p>
535 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
536 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
537 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
538 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
539 Any combination of the filter characters may be used.
540 When <tt>*</tt> (All-or-none) is added to the combination, all
541 paths are selected if there is any file that matches
542 other criteria in the comparison; if there is no file
543 that matches other criteria, nothing is selected.
544</p>
545</dd>
546<dt>
547--find-copies-harder
548</dt>
549<dd>
550<p>
551 For performance reasons, by default, -C option finds copies only
552 if the original file of the copy was modified in the same
553 changeset. This flag makes the command
554 inspect unmodified files as candidates for the source of
555 copy. This is a very expensive operation for large
556 projects, so use it with caution.
557</p>
558</dd>
559<dt>
560-l&lt;num&gt;
561</dt>
562<dd>
563<p>
564 -M and -C options require O(n^2) processing time where n
565 is the number of potential rename/copy targets. This
566 option prevents rename/copy detection from running if
567 the number of rename/copy targets exceeds the specified
568 number.
569</p>
570</dd>
571<dt>
572-S&lt;string&gt;
573</dt>
574<dd>
575<p>
576 Look for differences that contain the change in &lt;string&gt;.
577</p>
578</dd>
579<dt>
580--pickaxe-all
581</dt>
582<dd>
583<p>
584 When -S finds a change, show all the changes in that
585 changeset, not just the files that contain the change
586 in &lt;string&gt;.
587</p>
588</dd>
589<dt>
590--pickaxe-regex
591</dt>
592<dd>
593<p>
594 Make the &lt;string&gt; not a plain string but an extended POSIX
595 regex to match.
596</p>
597</dd>
598<dt>
599-O&lt;orderfile&gt;
600</dt>
601<dd>
602<p>
603 Output the patch in the order specified in the
604 &lt;orderfile&gt;, which has one shell glob pattern per line.
605</p>
606</dd>
607<dt>
608-R
609</dt>
610<dd>
611<p>
612 Swap two inputs; that is, show differences from index or
613 on-disk file to tree contents.
614</p>
615</dd>
616<dt>
617--text
618</dt>
619<dd>
620<p>
621 Treat all files as text.
622</p>
623</dd>
624<dt>
625-a
626</dt>
627<dd>
628<p>
629 Shorthand for "--text".
630</p>
631</dd>
632<dt>
633--ignore-space-change
634</dt>
635<dd>
636<p>
637 Ignore changes in amount of white space. This ignores white
638 space at line end, and consider all other sequences of one or
639 more white space characters to be equivalent.
640</p>
641</dd>
642<dt>
643-b
644</dt>
645<dd>
646<p>
647 Shorthand for "--ignore-space-change".
648</p>
649</dd>
650<dt>
651--ignore-all-space
652</dt>
653<dd>
654<p>
655 Ignore white space when comparing lines. This ignores
656 difference even if one line has white space where the other
657 line has none.
658</p>
659</dd>
660<dt>
661-w
662</dt>
663<dd>
664<p>
665 Shorthand for "--ignore-all-space".
666</p>
667</dd>
668</dl>
669<p>For more detailed explanation on these common options, see also
670<a href="diffcore.html">diffcore documentation</a>.</p>
671<dl>
672<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23673&lt;path&gt;&#8230;
674</dt>
675<dd>
676<p>
Junio C Hamano47848ae2006-12-14 11:20:06677 The &lt;paths&gt; parameters, when given, are used to limit
678 the diff to the named paths (you can give directory
679 names and get diff for all files under them).
Junio C Hamano1a4e8412005-12-27 08:17:23680</p>
681</dd>
682</dl>
683</div>
684<h2>EXAMPLES</h2>
685<div class="sectionbody">
686<dl>
687<dt>
688Various ways to check your working tree
689</dt>
690<dd>
691<div class="listingblock">
692<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01693<pre><tt>$ git diff <b>(1)</b>
Junio C Hamano47848ae2006-12-14 11:20:06694$ git diff --cached <b>(2)</b>
Junio C Hamanoc8d88c22006-04-29 07:02:01695$ git diff HEAD <b>(3)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23696</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01697<ol>
698<li>
699<p>
Junio C Hamano47848ae2006-12-14 11:20:06700changes in the working tree not yet staged for the next commit.
Junio C Hamanoc8d88c22006-04-29 07:02:01701</p>
702</li>
703<li>
704<p>
705changes between the index and your last commit; what you
706would be committing if you run "git commit" without "-a" option.
707</p>
708</li>
709<li>
710<p>
711changes in the working tree since your last commit; what you
712would be committing if you run "git commit -a"
713</p>
714</li>
715</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23716</dd>
717<dt>
718Comparing with arbitrary commits
719</dt>
720<dd>
721<div class="listingblock">
722<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01723<pre><tt>$ git diff test <b>(1)</b>
724$ git diff HEAD -- ./test <b>(2)</b>
725$ git diff HEAD^ HEAD <b>(3)</b></tt></pre>
726</div></div>
727<ol>
728<li>
729<p>
730instead of using the tip of the current branch, compare with the
Junio C Hamano1a4e8412005-12-27 08:17:23731tip of "test" branch.
Junio C Hamanoc8d88c22006-04-29 07:02:01732</p>
733</li>
734<li>
735<p>
736instead of comparing with the tip of "test" branch, compare with
Junio C Hamano235a91e2006-01-07 01:13:58737the tip of the current branch, but limit the comparison to the
Junio C Hamano1a4e8412005-12-27 08:17:23738file "test".
Junio C Hamanoc8d88c22006-04-29 07:02:01739</p>
740</li>
741<li>
742<p>
743compare the version before the last commit and the last commit.
744</p>
745</li>
746</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23747</dd>
748<dt>
749Limiting the diff output
750</dt>
751<dd>
752<div class="listingblock">
753<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01754<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>
755$ git diff --name-status -r <b>(2)</b>
756$ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>
757</div></div>
758<ol>
759<li>
760<p>
761show only modification, rename and copy, but not addition
Junio C Hamano1a4e8412005-12-27 08:17:23762nor deletion.
Junio C Hamanoc8d88c22006-04-29 07:02:01763</p>
764</li>
765<li>
766<p>
767show only names and the nature of change, but not actual
Junio C Hamano1a4e8412005-12-27 08:17:23768diff output. --name-status disables usual patch generation
Junio C Hamano341071d2006-06-04 07:24:48769which in turn also disables recursive behavior, so without -r
Junio C Hamano1a4e8412005-12-27 08:17:23770you would only see the directory name if there is a change in a
771file in a subdirectory.
Junio C Hamanoc8d88c22006-04-29 07:02:01772</p>
773</li>
774<li>
775<p>
776limit diff output to named subtrees.
777</p>
778</li>
779</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23780</dd>
781<dt>
782Munging the diff output
783</dt>
784<dd>
785<div class="listingblock">
786<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01787<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>
788$ git diff -R <b>(2)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23789</div></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01790<ol>
791<li>
792<p>
793spend extra cycles to find renames, copies and complete
794rewrites (very expensive).
795</p>
796</li>
797<li>
798<p>
799output diff in reverse.
800</p>
801</li>
802</ol>
Junio C Hamano1a4e8412005-12-27 08:17:23803</dd>
804</dl>
805</div>
806<h2>Author</h2>
807<div class="sectionbody">
808<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
809</div>
810<h2>Documentation</h2>
811<div class="sectionbody">
812<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
813</div>
814<h2>GIT</h2>
815<div class="sectionbody">
816<p>Part of the <a href="git.html">git(7)</a> suite</p>
817</div>
818<div id="footer">
819<div id="footer-text">
Junio C Hamanod793de52006-12-26 09:11:43820Last updated 26-Dec-2006 09:11:34 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23821</div>
822</div>
823</body>
824</html>