1GIT-DIFF(1)                       Git Manual                       GIT-DIFF(1)
2
3
4

NAME

6       git-diff - Show changes between commits, commit and working tree, etc
7

SYNOPSIS

9       git-diff [<common diff options>] <commit>{0,2} [--] [<path>...]
10

DESCRIPTION

12       Show changes between two trees, a tree and the working tree, a tree and
13       the index file, or the index file and the working tree.
14
15       git-diff [--options] [--] [<path>...]
16           This form is to view the changes you made relative to the index
17           (staging area for the next commit). In other words, the differences
18           are what you could tell git to further add to the index but you
19           still havenĀ“t. You can stage these changes by using git-add(1).
20
21           If exactly two paths are given, and at least one is untracked,
22           compare the two files / directories. This behavior can be forced by
23           --no-index.
24
25       git-diff [--options] --cached [<commit>] [--] [<path>...]
26           This form is to view the changes you staged for the next commit
27           relative to the named <commit>. Typically you would want comparison
28           with the latest commit, so if you do not give <commit>, it defaults
29           to HEAD.
30
31       git-diff [--options] <commit> [--] [<path>...]
32           This form is to view the changes you have in your working tree
33           relative to the named <commit>. You can use HEAD to compare it with
34           the latest commit, or a branch name to compare with the tip of a
35           different branch.
36
37       git-diff [--options] <commit> <commit> [--] [<path>...]
38           This is to view the changes between two arbitrary <commit>.
39
40       git-diff [--options] <commit>..<commit> [--] [<path>...]
41           This is synonymous to the previous form. If <commit> on one side is
42           omitted, it will have the same effect as using HEAD instead.
43
44       git-diff [--options] <commit>...<commit> [--] [<path>...]
45           This form is to view the changes on the branch containing and up to
46           the second <commit>, starting at a common ancestor of both
47           <commit>. "git-diff A...B" is equivalent to "git-diff
48           $(git-merge-base A B) B". You can omit any one of <commit>, which
49           has the same effect as using HEAD instead.
50       Just in case if you are doing something exotic, it should be noted that
51       all of the <commit> in the above description, except for the last two
52       forms that use ".." notations, can be any <tree-ish>.
53
54       For a more complete list of ways to spell <commit>, see "SPECIFYING
55       REVISIONS" section in git-rev-parse(1). However, "diff" is about
56       comparing two endpoints, not ranges, and the range notations
57       ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as
58       defined in the "SPECIFYING RANGES" section in git-rev-parse(1).
59

OPTIONS

61       -p
62           Generate patch (see section on generating patches)
63
64       -u
65           Synonym for "-p".
66
67       -U<n>
68           Shorthand for "--unified=<n>".
69
70       --unified=<n>
71           Generate diffs with <n> lines of context instead of the usual
72           three. Implies "-p".
73
74       --raw
75           Generate the raw format.
76
77       --patch-with-raw
78           Synonym for "-p --raw".
79
80       --stat[=width[,name-width]]
81           Generate a diffstat. You can override the default output width for
82           80-column terminal by "--stat=width". The width of the filename
83           part can be controlled by giving another width to it separated by a
84           comma.
85
86       --numstat
87           Similar to --stat, but shows number of added and deleted lines in
88           decimal notation and pathname without abbreviation, to make it more
89           machine friendly. For binary files, outputs two - instead of saying
90           0 0.
91
92       --shortstat
93           Output only the last line of the --stat format containing total
94           number of modified files, as well as number of added and deleted
95           lines.
96
97       --summary
98           Output a condensed summary of extended header information such as
99           creations, renames and mode changes.
100
101       --patch-with-stat
102           Synonym for "-p --stat".
103
104       -z
105           NUL-line termination on output. This affects the --raw output field
106           terminator. Also output from commands such as "git-log" will be
107           delimited with NUL between commits.
108
109       --name-only
110           Show only names of changed files.
111
112       --name-status
113           Show only names and status of changed files.
114
115       --color
116           Show colored diff.
117
118       --no-color
119           Turn off colored diff, even when the configuration file gives the
120           default to color output.
121
122       --color-words
123           Show colored word diff, i.e. color words which have changed.
124
125       --no-renames
126           Turn off rename detection, even when the configuration file gives
127           the default to do so.
128
129       --check
130           Warn if changes introduce trailing whitespace or an indent that
131           uses a space before a tab.
132
133       --full-index
134           Instead of the first handful characters, show full object name of
135           pre- and post-image blob on the "index" line when generating a
136           patch format output.
137
138       --binary
139           In addition to --full-index, output "binary diff" that can be
140           applied with "git apply".
141
142       --abbrev[=<n>]
143           Instead of showing the full 40-byte hexadecimal object name in
144           diff-raw format output and diff-tree header lines, show only
145           handful hexdigits prefix. This is independent of --full-index
146           option above, which controls the diff-patch output format. Non
147           default number of digits can be specified with --abbrev=<n>.
148
149       -B
150           Break complete rewrite changes into pairs of delete and create.
151
152       -M
153           Detect renames.
154
155       -C
156           Detect copies as well as renames. See also --find-copies-harder.
157
158       --diff-filter=[ACDMRTUXB*]
159           Select only files that are Added (A), Copied (C), Deleted (D),
160           Modified (M), Renamed (R), have their type (mode) changed (T), are
161           Unmerged (U), are Unknown (X), or have had their pairing Broken
162           (B). Any combination of the filter characters may be used. When *
163           (All-or-none) is added to the combination, all paths are selected
164           if there is any file that matches other criteria in the comparison;
165           if there is no file that matches other criteria, nothing is
166           selected.
167
168       --find-copies-harder
169           For performance reasons, by default, -C option finds copies only if
170           the original file of the copy was modified in the same changeset.
171           This flag makes the command inspect unmodified files as candidates
172           for the source of copy. This is a very expensive operation for
173           large projects, so use it with caution. Giving more than one -C
174           option has the same effect.
175
176       -l<num>
177           -M and -C options require O(n^2) processing time where n is the
178           number of potential rename/copy targets. This option prevents
179           rename/copy detection from running if the number of rename/copy
180           targets exceeds the specified number.
181
182       -S<string>
183           Look for differences that contain the change in <string>.
184
185       --pickaxe-all
186           When -S finds a change, show all the changes in that changeset, not
187           just the files that contain the change in <string>.
188
189       --pickaxe-regex
190           Make the <string> not a plain string but an extended POSIX regex to
191           match.
192
193       -O<orderfile>
194           Output the patch in the order specified in the <orderfile>, which
195           has one shell glob pattern per line.
196
197       -R
198           Swap two inputs; that is, show differences from index or on-disk
199           file to tree contents.
200
201       --text
202           Treat all files as text.
203
204       -a
205           Shorthand for "--text".
206
207       --ignore-space-at-eol
208           Ignore changes in white spaces at EOL.
209
210       --ignore-space-change
211           Ignore changes in amount of white space. This ignores white space
212           at line end, and consider all other sequences of one or more white
213           space characters to be equivalent.
214
215       -b
216           Shorthand for "--ignore-space-change".
217
218       --ignore-all-space
219           Ignore white space when comparing lines. This ignores difference
220           even if one line has white space where the other line has none.
221
222       -w
223           Shorthand for "--ignore-all-space".
224
225       --exit-code
226           Make the program exit with codes similar to diff(1). That is, it
227           exits with 1 if there were differences and 0 means no differences.
228
229       --quiet
230           Disable all output of the program. Implies --exit-code.
231
232       --ext-diff
233           Allow an external diff helper to be executed. If you set an
234           external diff driver with gitlink:gitattributes(5), you need to use
235           this option with gitlink:git-log(1) and friends.
236
237       --no-ext-diff
238           Disallow external diff drivers.
239       For more detailed explanation on these common options, see also
240       diffcore documentation[1].
241
242       <path>...
243           The <paths> parameters, when given, are used to limit the diff to
244           the named paths (you can give directory names and get diff for all
245           files under them).
246

EXAMPLES

248       Various ways to check your working tree
249
250
251               $ git diff            (1)
252               $ git diff --cached   (2)
253               $ git diff HEAD       (3)
254
255
256           1. Changes in the working tree not yet staged for the next commit.
257           2. Changes between the index and your last commit; what you would
258           be committing if you run "git commit" without "-a" option.
259           3. Changes in the working tree since your last commit; what you
260           would be committing if you run "git commit -a"
261
262       Comparing with arbitrary commits
263
264
265               $ git diff test            (1)
266               $ git diff HEAD -- ./test  (2)
267               $ git diff HEAD^ HEAD      (3)
268
269
270           1. Instead of using the tip of the current branch, compare with the
271           tip of "test" branch.
272           2. Instead of comparing with the tip of "test" branch, compare with
273           the tip of the current branch, but limit the comparison to the file
274           "test".
275           3. Compare the version before the last commit and the last commit.
276
277       Comparing branches
278
279
280               $ git diff topic master    (1)
281               $ git diff topic..master   (2)
282               $ git diff topic...master  (3)
283
284
285           1. Changes between the tips of the topic and the master branches.
286           2. Same as above.
287           3. Changes that occured on the master branch since when the topic
288           branch was started off it.
289
290       Limiting the diff output
291
292
293               $ git diff --diff-filter=MRC            (1)
294               $ git diff --name-status                (2)
295               $ git diff arch/i386 include/asm-i386   (3)
296
297
298           1. Show only modification, rename and copy, but not addition nor
299           deletion.
300           2. Show only names and the nature of change, but not actual diff
301           output.
302           3. Limit diff output to named subtrees.
303
304       Munging the diff output
305
306
307               $ git diff --find-copies-harder -B -C  (1)
308               $ git diff -R                          (2)
309
310
311           1. Spend extra cycles to find renames, copies and complete rewrites
312           (very expensive).
313           2. Output diff in reverse.
314

AUTHOR

316       Written by Linus Torvalds <torvalds@osdl.org>
317

DOCUMENTATION

319       Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
320

GIT

322       Part of the git(7) suite
323

NOTES

325        1. diffcore documentation
326           diffcore.html
327
328
329
330Git 1.5.3.3                       10/09/2007                       GIT-DIFF(1)
Impressum