]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/diff-options.txt
repo-settings: rename the traditional default fetch.negotiationAlgorithm
[thirdparty/git.git] / Documentation / diff-options.txt
CommitLineData
c1a95fa6
SO
1// Please don't remove this comment as asciidoc behaves badly when
2// the first non-empty line is ifdef/ifndef. The symptom is that
3// without this comment the <git-diff-core> attribute conditionally
4// defined below ends up being defined unconditionally.
5// Last checked with asciidoc 7.0.2.
6
7ifndef::git-format-patch[]
8ifndef::git-diff[]
272bd3cf 9ifndef::git-log[]
c1a95fa6 10:git-diff-core: 1
272bd3cf 11endif::git-log[]
c1a95fa6
SO
12endif::git-diff[]
13endif::git-format-patch[]
14
15ifdef::git-format-patch[]
16-p::
2cfa8330 17--no-stat::
02bc5b03 18 Generate plain patches without any diffstats.
c1a95fa6
SO
19endif::git-format-patch[]
20
21ifndef::git-format-patch[]
dda2d79a 22-p::
a9e67c8c 23-u::
1c9eecff 24--patch::
c1a95fa6 25 Generate patch (see section on generating patches).
d0258b93
JK
26ifdef::git-diff[]
27 This is the default.
28endif::git-diff[]
dda2d79a 29
7b02c834
MM
30-s::
31--no-patch::
32 Suppress diff output. Useful for commands like `git show` that
33 show the patch by default, or to cancel the effect of `--patch`.
b73a1bcc 34endif::git-format-patch[]
7b02c834 35
1d24509b 36ifdef::git-log[]
364bc11f 37--diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc)::
1d24509b
SO
38--no-diff-merges::
39 Specify diff format to be used for merge commits. Default is
40 {diff-merges-default} unless `--first-parent` is in use, in which case
41 `first-parent` is the default.
42+
43--diff-merges=(off|none):::
44--no-diff-merges:::
45 Disable output of diffs for merge commits. Useful to override
46 implied value.
47+
364bc11f
SO
48--diff-merges=on:::
49--diff-merges=m:::
50-m:::
51 This option makes diff output for merge commits to be shown in
6a38e333
JN
52 the default format. `-m` will produce the output only if `-p`
53 is given as well. The default format could be changed using
364bc11f 54 `log.diffMerges` configuration parameter, which default value
6a38e333 55 is `separate`.
364bc11f 56+
1d24509b
SO
57--diff-merges=first-parent:::
58--diff-merges=1:::
59 This option makes merge commits show the full diff with
60 respect to the first parent only.
61+
62--diff-merges=separate:::
1d24509b
SO
63 This makes merge commits show the full diff with respect to
64 each of the parents. Separate log entry and diff is generated
6a38e333 65 for each parent.
1d24509b
SO
66+
67--diff-merges=combined:::
68--diff-merges=c:::
69-c:::
70 With this option, diff output for a merge commit shows the
71 differences from each of the parents to the merge result
72 simultaneously instead of showing pairwise diff between a
73 parent and the result one at a time. Furthermore, it lists
74 only files which were modified from all parents. `-c` implies
75 `-p`.
76+
77--diff-merges=dense-combined:::
78--diff-merges=cc:::
79--cc:::
80 With this option the output produced by
81 `--diff-merges=combined` is further compressed by omitting
82 uninteresting hunks whose contents in the parents have only
83 two variants and the merge result picks one of them without
84 modification. `--cc` implies `-p`.
85
86--combined-all-paths::
87 This flag causes combined diffs (used for merge commits) to
88 list the name of the file from all parents. It thus only has
89 effect when `--diff-merges=[dense-]combined` is in use, and
90 is likely only useful if filename changes are detected (i.e.
91 when either rename or copy detection have been requested).
92endif::git-log[]
93
4eb99473 94-U<n>::
4eb99473
RR
95--unified=<n>::
96 Generate diffs with <n> lines of context instead of
714d491a 97 the usual three.
02bc5b03 98ifndef::git-format-patch[]
714d491a 99 Implies `--patch`.
02bc5b03 100endif::git-format-patch[]
4eb99473 101
af2f3680
NTND
102--output=<file>::
103 Output to a specific file instead of stdout.
104
105--output-indicator-new=<char>::
106--output-indicator-old=<char>::
107--output-indicator-context=<char>::
108 Specify the character used to indicate new, old or context
109 lines in the generated patch. Normally they are '+', '-' and
110 ' ' respectively.
111
d4cb003f 112ifndef::git-format-patch[]
b5376648 113--raw::
d89df367
MM
114ifndef::git-log[]
115 Generate the diff in raw format.
d0258b93
JK
116ifdef::git-diff-core[]
117 This is the default.
118endif::git-diff-core[]
d89df367
MM
119endif::git-log[]
120ifdef::git-log[]
121 For each commit, show a summary of changes using the raw diff
122 format. See the "RAW OUTPUT FORMAT" section of
123 linkgit:git-diff[1]. This is different from showing the log
124 itself in raw format, which you can achieve with
125 `--format=raw`.
126endif::git-log[]
d4cb003f 127endif::git-format-patch[]
b5376648 128
02bc5b03 129ifndef::git-format-patch[]
5c91da25 130--patch-with-raw::
dce5ef14 131 Synonym for `-p --raw`.
02bc5b03 132endif::git-format-patch[]
5c91da25 133
9a6d515f
JK
134ifdef::git-log[]
135-t::
136 Show the tree objects in the diff output.
137endif::git-log[]
138
bab76141 139--indent-heuristic::
7eedad15 140 Enable the heuristic that shifts diff hunk boundaries to make patches
bab76141
CMN
141 easier to read. This is the default.
142
143--no-indent-heuristic::
144 Disable the indent heuristic.
5580b271 145
81b568c8
JH
146--minimal::
147 Spend extra time to make sure the smallest possible
148 diff is produced.
149
ec74042d 150--patience::
34292bdd
JS
151 Generate a diff using the "patience diff" algorithm.
152
d909e076
TR
153--histogram::
154 Generate a diff using the "histogram diff" algorithm.
155
2477ab2e
JT
156--anchored=<text>::
157 Generate a diff using the "anchored diff" algorithm.
158+
159This option may be specified more than once.
160+
161If a line exists in both the source and destination, exists only once,
162and starts with this text, this algorithm attempts to prevent it from
163appearing as a deletion or addition in the output. It uses the "patience
164diff" algorithm internally.
165
07924d4d
MP
166--diff-algorithm={patience|minimal|histogram|myers}::
167 Choose a diff algorithm. The variants are as follows:
168+
169--
170`default`, `myers`;;
171 The basic greedy diff algorithm. Currently, this is the default.
172`minimal`;;
173 Spend extra time to make sure the smallest possible diff is
174 produced.
175`patience`;;
176 Use "patience diff" algorithm when generating patches.
177`histogram`;;
178 This algorithm extends the patience algorithm to "support
179 low-occurrence common elements".
180--
181+
7eedad15 182For instance, if you configured the `diff.algorithm` variable to a
07924d4d
MP
183non-default value and want to use the default one, then you
184have to use `--diff-algorithm=default` option.
185
808e1db2 186--stat[=<width>[,<name-width>[,<count>]]]::
1b058bc3 187 Generate a diffstat. By default, as much space as necessary
df44483a
ZJS
188 will be used for the filename part, and the rest for the graph
189 part. Maximum width defaults to terminal width, or 80 columns
8d8136c3 190 if not connected to a terminal, and can be overridden by
df44483a
ZJS
191 `<width>`. The width of the filename part can be limited by
192 giving another width `<name-width>` after a comma. The width
193 of the graph part can be limited by using
194 `--stat-graph-width=<width>` (affects all commands generating
195 a stat graph) or by setting `diff.statGraphWidth=<width>`
196 (does not affect `git format-patch`).
808e1db2 197 By giving a third parameter `<count>`, you can limit the
1b058bc3
ZJS
198 output to the first `<count>` lines, followed by `...` if
199 there are more.
86e1ce96
MG
200+
201These parameters can also be set individually with `--stat-width=<width>`,
202`--stat-name-width=<name-width>` and `--stat-count=<count>`.
d75f7952 203
ddf88fa6
NTND
204--compact-summary::
205 Output a condensed summary of extended header information such
206 as file creations or deletions ("new" or "gone", optionally "+l"
207 if it's a symlink) and mode changes ("+x" or "-x" for adding
208 or removing executable bit respectively) in diffstat. The
1f2abe68 209 information is put between the filename part and the graph
ddf88fa6
NTND
210 part. Implies `--stat`.
211
74e2abe5 212--numstat::
6cf378f0 213 Similar to `--stat`, but shows number of added and
74e2abe5 214 deleted lines in decimal notation and pathname without
2f89543e
JH
215 abbreviation, to make it more machine friendly. For
216 binary files, outputs two `-` instead of saying
217 `0 0`.
74e2abe5 218
ebd124c6 219--shortstat::
dce5ef14 220 Output only the last line of the `--stat` format containing total
ebd124c6
NP
221 number of modified files, as well as number of added and deleted
222 lines.
223
4ce7aab5 224-X[<param1,param2,...>]::
333f3fb0
JH
225--dirstat[=<param1,param2,...>]::
226 Output the distribution of relative amount of changes for each
227 sub-directory. The behavior of `--dirstat` can be customized by
228 passing it a comma separated list of parameters.
2d174951
JH
229 The defaults are controlled by the `diff.dirstat` configuration
230 variable (see linkgit:git-config[1]).
333f3fb0 231 The following parameters are available:
204f01a2 232+
333f3fb0
JH
233--
234`changes`;;
235 Compute the dirstat numbers by counting the lines that have been
236 removed from the source, or added to the destination. This ignores
237 the amount of pure code movements within a file. In other words,
238 rearranging lines in a file is not counted as much as other changes.
239 This is the default behavior when no parameter is given.
1c57a627
JH
240`lines`;;
241 Compute the dirstat numbers by doing the regular line-based diff
242 analysis, and summing the removed/added line counts. (For binary
243 files, count 64-byte chunks instead, since binary files have no
244 natural concept of lines). This is a more expensive `--dirstat`
245 behavior than the `changes` behavior, but it does count rearranged
246 lines within a file as much as other changes. The resulting output
247 is consistent with what you get from the other `--*stat` options.
333f3fb0
JH
248`files`;;
249 Compute the dirstat numbers by counting the number of files changed.
250 Each changed file counts equally in the dirstat analysis. This is
251 the computationally cheapest `--dirstat` behavior, since it does
252 not have to look at the file contents at all.
253`cumulative`;;
254 Count changes in a child directory for the parent directory as well.
255 Note that when using `cumulative`, the sum of the percentages
256 reported may exceed 100%. The default (non-cumulative) behavior can
257 be specified with the `noncumulative` parameter.
258<limit>;;
259 An integer parameter specifies a cut-off percent (3% by default).
260 Directories contributing less than this percentage of the changes
261 are not shown in the output.
262--
263+
264Example: The following will count changed files, while ignoring
265directories with less than 10% of the total amount of changed files,
266and accumulating child directory counts in the parent directories:
267`--dirstat=files,10,cumulative`.
fd33777b 268
4ce7aab5
NTND
269--cumulative::
270 Synonym for --dirstat=cumulative
271
272--dirstat-by-file[=<param1,param2>...]::
273 Synonym for --dirstat=files,param1,param2...
274
4bbd261b
SE
275--summary::
276 Output a condensed summary of extended header information
277 such as creations, renames and mode changes.
278
02bc5b03 279ifndef::git-format-patch[]
29353273 280--patch-with-stat::
dce5ef14 281 Synonym for `-p --stat`.
02bc5b03 282endif::git-format-patch[]
29353273 283
d4cb003f 284ifndef::git-format-patch[]
64485b4a 285
dda2d79a 286-z::
5c931c8d
BG
287ifdef::git-log[]
288 Separate the commits with NULs instead of with new newlines.
289+
290Also, when `--raw` or `--numstat` has been given, do not munge
291pathnames and use NULs as output field terminators.
292endif::git-log[]
64485b4a 293ifndef::git-log[]
03aa87ed
CB
294 When `--raw`, `--numstat`, `--name-only` or `--name-status` has been
295 given, do not munge pathnames and use NULs as output field terminators.
5c931c8d 296endif::git-log[]
64485b4a 297+
860cd699
AH
298Without this option, pathnames with "unusual" characters are quoted as
299explained for the configuration variable `core.quotePath` (see
300linkgit:git-config[1]).
dda2d79a
JH
301
302--name-only::
9364bf46
AB
303 Show only names of changed files. The file names are often encoded in UTF-8.
304 For more information see the discussion about encoding in the linkgit:git-log[1]
305 manual page.
dda2d79a 306
946f5f7c 307--name-status::
a6f47b2b
MV
308 Show only names and status of changed files. See the description
309 of the `--diff-filter` option on what the status letters mean.
9364bf46 310 Just like `--name-only` the file names are often encoded in UTF-8.
dda2d79a 311
752c0c24 312--submodule[=<format>]::
fd47ae6a
JK
313 Specify how differences in submodules are shown. When specifying
314 `--submodule=short` the 'short' format is used. This format just
315 shows the names of the commits at the beginning and end of the range.
316 When `--submodule` or `--submodule=log` is specified, the 'log'
317 format is used. This format lists the commits in the range like
318 linkgit:git-submodule[1] `summary` does. When `--submodule=diff`
319 is specified, the 'diff' format is used. This format shows an
320 inline diff of the changes in the submodule contents between the
321 commit range. Defaults to `diff.submodule` or the 'short' format
322 if the config option is unset.
752c0c24 323
73e9da01 324--color[=<when>]::
b5376648 325 Show colored diff.
3d0e75f2
JH
326 `--color` (i.e. without '=<when>') is the same as `--color=always`.
327 '<when>' can be one of `always`, `never`, or `auto`.
6999c540
MG
328ifdef::git-diff[]
329 It can be changed by the `color.ui` and `color.diff`
330 configuration settings.
331endif::git-diff[]
b5376648
JH
332
333--no-color::
6999c540
MG
334 Turn off colored diff.
335ifdef::git-diff[]
336 This can be used to override configuration settings.
337endif::git-diff[]
338 It is the same as `--color=never`.
b5376648 339
61e89eaa
SB
340--color-moved[=<mode>]::
341 Moved lines of code are colored differently.
342ifdef::git-diff[]
343 It can be changed by the `diff.colorMoved` configuration setting.
344endif::git-diff[]
345 The <mode> defaults to 'no' if the option is not given
346 and to 'zebra' if the option with no mode is given.
347 The mode must be one of:
348+
349--
350no::
351 Moved lines are not highlighted.
352default::
353 Is a synonym for `zebra`. This may change to a more sensible mode
354 in the future.
355plain::
356 Any line that is added in one location and was removed
357 in another location will be colored with 'color.diff.newMoved'.
358 Similarly 'color.diff.oldMoved' will be used for removed lines
359 that are added somewhere else in the diff. This mode picks up any
360 moved line, but it is not very useful in a review to determine
361 if a block of code was moved without permutation.
51da15eb 362blocks::
f0b8fb6e
JT
363 Blocks of moved text of at least 20 alphanumeric characters
364 are detected greedily. The detected blocks are
51da15eb
SB
365 painted using either the 'color.diff.{old,new}Moved' color.
366 Adjacent blocks cannot be told apart.
367zebra::
368 Blocks of moved text are detected as in 'blocks' mode. The blocks
369 are painted using either the 'color.diff.{old,new}Moved' color or
61e89eaa 370 'color.diff.{old,new}MovedAlternative'. The change between
f0b8fb6e 371 the two colors indicates that a new block was detected.
e3f2f5f9 372dimmed-zebra::
61e89eaa
SB
373 Similar to 'zebra', but additional dimming of uninteresting parts
374 of moved code is performed. The bordering lines of two adjacent
375 blocks are considered interesting, the rest is uninteresting.
e3f2f5f9 376 `dimmed_zebra` is a deprecated synonym.
61e89eaa
SB
377--
378
fbafb7c6
PW
379--no-color-moved::
380 Turn off move detection. This can be used to override configuration
381 settings. It is the same as `--color-moved=no`.
382
b3095712 383--color-moved-ws=<modes>::
748aa1aa 384 This configures how whitespace is ignored when performing the
626c0b5d
SB
385 move detection for `--color-moved`.
386ifdef::git-diff[]
387 It can be set by the `diff.colorMovedWS` configuration setting.
388endif::git-diff[]
389 These modes can be given as a comma separated list:
b3095712
SB
390+
391--
b73bcbac
PW
392no::
393 Do not ignore whitespace when performing move detection.
b3095712
SB
394ignore-space-at-eol::
395 Ignore changes in whitespace at EOL.
396ignore-space-change::
397 Ignore changes in amount of whitespace. This ignores whitespace
398 at line end, and considers all other sequences of one or
399 more whitespace characters to be equivalent.
400ignore-all-space::
401 Ignore whitespace when comparing lines. This ignores differences
402 even if one line has whitespace where the other line has none.
ca1f4ae4 403allow-indentation-change::
748aa1aa 404 Initially ignore any whitespace in the move detection, then
ca1f4ae4
SB
405 group the moved code blocks only into a block if the change in
406 whitespace is the same per line. This is incompatible with the
407 other modes.
b3095712
SB
408--
409
b73bcbac
PW
410--no-color-moved-ws::
411 Do not ignore whitespace when performing move detection. This can be
412 used to override configuration settings. It is the same as
413 `--color-moved-ws=no`.
414
882749a0
TR
415--word-diff[=<mode>]::
416 Show a word diff, using the <mode> to delimit changed words.
417 By default, words are delimited by whitespace; see
418 `--word-diff-regex` below. The <mode> defaults to 'plain', and
419 must be one of:
420+
421--
422color::
423 Highlight changed words using only colors. Implies `--color`.
424plain::
425 Show words as `[-removed-]` and `{+added+}`. Makes no
426 attempts to escape the delimiters if they appear in the input,
427 so the output may be ambiguous.
428porcelain::
429 Use a special line-based format intended for script
430 consumption. Added/removed/unchanged runs are printed in the
431 usual unified diff format, starting with a `+`/`-`/` `
432 character at the beginning of the line and extending to the
433 end of the line. Newlines in the input are represented by a
434 tilde `~` on a line of its own.
435none::
436 Disable word diff again.
437--
438+
439Note that despite the name of the first mode, color is used to
440highlight the changed parts in all modes if enabled.
441
442--word-diff-regex=<regex>::
443 Use <regex> to decide what a word is, instead of considering
444 runs of non-whitespace to be a word. Also implies
445 `--word-diff` unless it was already enabled.
2b6a5417 446+
882749a0 447Every non-overlapping match of the
c4b252c3
TR
448<regex> is considered a word. Anything between these matches is
449considered whitespace and ignored(!) for the purposes of finding
450differences. You may want to append `|[^[:space:]]` to your regular
451expression to make sure that it matches all non-whitespace characters.
452A match that contains a newline is silently truncated(!) at the
453newline.
80c49c3d 454+
2c15c006
MG
455For example, `--word-diff-regex=.` will treat each character as a word
456and, correspondingly, show differences character by character.
457+
98a4d87b 458The regex can also be set via a diff driver or configuration option, see
1cca17df 459linkgit:gitattributes[5] or linkgit:git-config[1]. Giving it explicitly
98a4d87b
BSSJ
460overrides any diff driver or configuration setting. Diff drivers
461override configuration settings.
882749a0
TR
462
463--color-words[=<regex>]::
464 Equivalent to `--word-diff=color` plus (if a regex was
465 specified) `--word-diff-regex=<regex>`.
d4cb003f 466endif::git-format-patch[]
f59a59e2 467
b5376648
JH
468--no-renames::
469 Turn off rename detection, even when the configuration
470 file gives the default to do so.
471
cdc43eb0
NTND
472--[no-]rename-empty::
473 Whether to use empty blobs as rename source.
474
02bc5b03 475ifndef::git-format-patch[]
16507fcf 476--check::
30211fb6
OA
477 Warn if changes introduce conflict markers or whitespace errors.
478 What are considered whitespace errors is controlled by `core.whitespace`
4f830390 479 configuration. By default, trailing whitespaces (including
7eedad15 480 lines that consist solely of whitespaces) and a space character
4f830390
CK
481 that is immediately followed by a tab character inside the
482 initial indent of the line are considered whitespace errors.
483 Exits with non-zero status if problems are found. Not compatible
484 with --exit-code.
b8767f79
JH
485
486--ws-error-highlight=<kind>::
c0bb6d9c
AH
487 Highlight whitespace errors in the `context`, `old` or `new`
488 lines of the diff. Multiple values are separated by comma,
489 `none` resets previous values, `default` reset the list to
490 `new` and `all` is a shorthand for `old,new,context`. When
491 this option is not given, and the configuration variable
492 `diff.wsErrorHighlight` is not set, only whitespace errors in
493 `new` lines are highlighted. The whitespace errors are colored
7eedad15 494 with `color.diff.whitespace`.
b8767f79 495
02bc5b03 496endif::git-format-patch[]
16507fcf 497
80b1e511 498--full-index::
6457e58c
JM
499 Instead of the first handful of characters, show the full
500 pre- and post-image blob object names on the "index"
501 line when generating patch format output.
b5376648
JH
502
503--binary::
dce5ef14 504 In addition to `--full-index`, output a binary diff that
714d491a
SO
505 can be applied with `git-apply`.
506ifndef::git-format-patch[]
507 Implies `--patch`.
508endif::git-format-patch[]
80b1e511 509
913419fc 510--abbrev[=<n>]::
47dd0d59
JH
511 Instead of showing the full 40-byte hexadecimal object
512 name in diff-raw format output and diff-tree header
cda34e0d
JH
513 lines, show the shortest prefix that is at least '<n>'
514 hexdigits long that uniquely refers the object.
3046c7f6
ĐTCD
515 In diff-patch output format, `--full-index` takes higher
516 precedence, i.e. if `--full-index` is specified, full blob
517 names will be shown regardless of `--abbrev`.
518 Non default number of digits can be specified with `--abbrev=<n>`.
47dd0d59 519
cf958afd 520-B[<n>][/<m>]::
37ab5156 521--break-rewrites[=[<n>][/<m>]]::
cf958afd
MM
522 Break complete rewrite changes into pairs of delete and
523 create. This serves two purposes:
524+
525It affects the way a change that amounts to a total rewrite of a file
526not as a series of deletion and insertion mixed together with a very
527few lines that happen to match textually as the context, but as a
528single deletion of everything old followed by a single insertion of
529everything new, and the number `m` controls this aspect of the -B
530option (defaults to 60%). `-B/70%` specifies that less than 30% of the
2de9b711 531original should remain in the result for Git to consider it a total
cf958afd
MM
532rewrite (i.e. otherwise the resulting patch will be a series of
533deletion and insertion mixed together with context lines).
534+
535When used with -M, a totally-rewritten file is also considered as the
536source of a rename (usually -M only considers a file that disappeared
537as the source of a rename), and the number `n` controls this aspect of
538the -B option (defaults to 50%). `-B20%` specifies that a change with
539addition and deletion compared to 20% or more of the file's size are
540eligible for being picked up as a possible source of a rename to
541another file.
542
543-M[<n>]::
f611ddc7 544--find-renames[=<n>]::
7ffad250 545ifndef::git-log[]
dda2d79a 546 Detect renames.
7ffad250
JK
547endif::git-log[]
548ifdef::git-log[]
549 If generating diffs, detect and report renames for each commit.
550 For following files across renames while traversing history, see
551 `--follow`.
552endif::git-log[]
4c007ae8 553 If `n` is specified, it is a threshold on the similarity
cf958afd 554 index (i.e. amount of addition/deletions compared to the
2de9b711 555 file's size). For example, `-M90%` means Git should consider a
cf958afd 556 delete/add pair to be a rename if more than 90% of the file
31d66aa4
SC
557 hasn't changed. Without a `%` sign, the number is to be read as
558 a fraction, with a decimal point before it. I.e., `-M5` becomes
559 0.5, and is thus the same as `-M50%`. Similarly, `-M05` is
560 the same as `-M5%`. To limit detection to exact renames, use
8240943b 561 `-M100%`. The default similarity index is 50%.
dda2d79a 562
cf958afd 563-C[<n>]::
f611ddc7 564--find-copies[=<n>]::
ca6c0970 565 Detect copies as well as renames. See also `--find-copies-harder`.
cf958afd 566 If `n` is specified, it has the same meaning as for `-M<n>`.
dda2d79a
JH
567
568--find-copies-harder::
ca6c0970 569 For performance reasons, by default, `-C` option finds copies only
a6080a0a 570 if the original file of the copy was modified in the same
f73ae1fc 571 changeset. This flag makes the command
dda2d79a
JH
572 inspect unmodified files as candidates for the source of
573 copy. This is a very expensive operation for large
ca6c0970
JS
574 projects, so use it with caution. Giving more than one
575 `-C` option has the same effect.
dda2d79a 576
467ddc14
JH
577-D::
578--irreversible-delete::
579 Omit the preimage for deletes, i.e. print only the header but not
580 the diff between the preimage and `/dev/null`. The resulting patch
a58088ab 581 is not meant to be applied with `patch` or `git apply`; this is
467ddc14 582 solely for people who want to just concentrate on reviewing the
bc9b7e20 583 text after the change. In addition, the output obviously lacks
467ddc14
JH
584 enough information to apply such a patch in reverse, even manually,
585 hence the name of the option.
586+
587When used together with `-B`, omit also the preimage in the deletion part
588of a delete/create pair.
589
8082d8d3 590-l<num>::
6623a528
EN
591 The `-M` and `-C` options involve some preliminary steps that
592 can detect subsets of renames/copies cheaply, followed by an
593 exhaustive fallback portion that compares all remaining
594 unpaired destinations to all relevant sources. (For renames,
595 only remaining unpaired sources are relevant; for copies, all
596 original sources are relevant.) For N sources and
597 destinations, this exhaustive check is O(N^2). This option
598 prevents the exhaustive portion of rename/copy detection from
599 running if the number of source/destination files involved
600 exceeds the specified number. Defaults to diff.renameLimit.
9dd29dbe 601 Note that a value of 0 is treated as unlimited.
8082d8d3 602
d4cb003f 603ifndef::git-format-patch[]
f1037448
YD
604--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]::
605 Select only files that are Added (`A`), Copied (`C`),
606 Deleted (`D`), Modified (`M`), Renamed (`R`), have their
607 type (i.e. regular file, symlink, submodule, ...) changed (`T`),
608 are Unmerged (`U`), are
609 Unknown (`X`), or have had their pairing Broken (`B`).
610 Any combination of the filter characters (including none) can be used.
611 When `*` (All-or-none) is added to the combination, all
612 paths are selected if there is any file that matches
613 other criteria in the comparison; if there is no file
614 that matches other criteria, nothing is selected.
16726cfa
JH
615+
616Also, these upper-case letters can be downcased to exclude. E.g.
617`--diff-filter=ad` excludes added and deleted paths.
46af107b
JK
618+
619Note that not all diffs can feature all types. For instance, diffs
620from the index to the working tree can never have Added entries
621(because the set of paths included in the diff is limited by what is in
622the index). Similarly, copied and renamed entries cannot appear if
623detection for those types is disabled.
f1037448 624
dda2d79a 625-S<string>::
5bc3f0b5
RR
626 Look for differences that change the number of occurrences of
627 the specified string (i.e. addition/deletion) in a file.
628 Intended for the scripter's use.
629+
630It is useful when you're looking for an exact block of code (like a
631struct), and want to know the history of that block since it first
632came into being: use the feature iteratively to feed the interesting
633block in the preimage back into `-S`, and keep going until you get the
634very first version of the block.
e0e7cb80
TB
635+
636Binary files are searched as well.
dda2d79a 637
f506b8e8 638-G<regex>::
5bc3f0b5
RR
639 Look for differences whose patch text contains added/removed
640 lines that match <regex>.
641+
642To illustrate the difference between `-S<regex> --pickaxe-regex` and
643`-G<regex>`, consider a commit with the following diff in the same
644file:
645+
646----
9299f849 647+ return frotz(nitfol, two->ptr, 1, 0);
5bc3f0b5 648...
9299f849 649- hit = frotz(nitfol, mf2.ptr, 1, 0);
5bc3f0b5
RR
650----
651+
9299f849
652While `git log -G"frotz\(nitfol"` will show this commit, `git log
653-S"frotz\(nitfol" --pickaxe-regex` will not (because the number of
5bc3f0b5
RR
654occurrences of that string did not change).
655+
e0e7cb80
TB
656Unless `--text` is supplied patches of binary files without a textconv
657filter will be ignored.
658+
5bc3f0b5
RR
659See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
660information.
f506b8e8 661
15af58c1
SB
662--find-object=<object-id>::
663 Look for differences that change the number of occurrences of
664 the specified object. Similar to `-S`, just the argument is different
665 in that it doesn't search for a specific string but for a specific
666 object id.
667+
668The object can be a blob or a submodule commit. It implies the `-t` option in
669`git-log` to also find trees.
670
dda2d79a 671--pickaxe-all::
f506b8e8 672 When `-S` or `-G` finds a change, show all the changes in that
f73ae1fc 673 changeset, not just the files that contain the change
dda2d79a
JH
674 in <string>.
675
d01d8c67 676--pickaxe-regex::
5bc3f0b5
RR
677 Treat the <string> given to `-S` as an extended POSIX regular
678 expression to match.
15af58c1 679
d4cb003f 680endif::git-format-patch[]
d01d8c67 681
dda2d79a 682-O<orderfile>::
874444b7 683 Control the order in which files appear in the output.
da0005b8
NTND
684 This overrides the `diff.orderFile` configuration variable
685 (see linkgit:git-config[1]). To cancel `diff.orderFile`,
6d8940b5 686 use `-O/dev/null`.
874444b7
RH
687+
688The output order is determined by the order of glob patterns in
689<orderfile>.
690All files with pathnames that match the first pattern are output
691first, all files with pathnames that match the second pattern (but not
692the first) are output next, and so on.
693All files with pathnames that do not match any pattern are output
694last, as if there was an implicit match-all pattern at the end of the
695file.
696If multiple pathnames have the same rank (they match the same pattern
697but no earlier patterns), their output order relative to each other is
698the normal order.
699+
700<orderfile> is parsed as follows:
701+
702--
703 - Blank lines are ignored, so they can be used as separators for
704 readability.
705
706 - Lines starting with a hash ("`#`") are ignored, so they can be used
707 for comments. Add a backslash ("`\`") to the beginning of the
708 pattern if it starts with a hash.
709
710 - Each other line contains a single pattern.
711--
712+
713Patterns have the same syntax and semantics as patterns used for
c30d4f1b 714fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
874444b7
RH
715matches a pattern if removing any number of the final pathname
716components matches the pattern. For example, the pattern "`foo*bar`"
717matches "`fooasdfbar`" and "`foo/bar/baz/asdf`" but not "`foobarx`".
dda2d79a 718
1eb4136a
JH
719--skip-to=<file>::
720--rotate-to=<file>::
721 Discard the files before the named <file> from the output
722 (i.e. 'skip to'), or move them to the end of the output
723 (i.e. 'rotate to'). These were invented primarily for use
724 of the `git difftool` command, and may not be very useful
725 otherwise.
726
d4cb003f 727ifndef::git-format-patch[]
dda2d79a 728-R::
5f3aa197 729 Swap two inputs; that is, show differences from index or
dda2d79a 730 on-disk file to tree contents.
c28ded83 731endif::git-format-patch[]
dda2d79a 732
c0cb4a06 733--relative[=<path>]::
c28ded83 734--no-relative::
cd676a51
JH
735 When run from a subdirectory of the project, it can be
736 told to exclude changes outside the directory and show
c0cb4a06
JH
737 pathnames relative to it with this option. When you are
738 not in a subdirectory (e.g. in a bare repository), you
739 can name which subdirectory to make the output relative
740 to by giving a <path> as an argument.
c28ded83
LA
741 `--no-relative` can be used to countermand both `diff.relative` config
742 option and previous `--relative`.
cd676a51 743
a9e67c8c 744-a::
d507bb15
SF
745--text::
746 Treat all files as text.
747
e9282f02 748--ignore-cr-at-eol::
c30d4f1b 749 Ignore carriage-return at the end of line when doing a comparison.
e9282f02 750
a44a0c99 751--ignore-space-at-eol::
0ac7903e 752 Ignore changes in whitespace at EOL.
a44a0c99 753
a9e67c8c 754-b::
8ebe185b 755--ignore-space-change::
0ac7903e
WC
756 Ignore changes in amount of whitespace. This ignores whitespace
757 at line end, and considers all other sequences of one or
758 more whitespace characters to be equivalent.
8ebe185b 759
a9e67c8c 760-w::
8ebe185b 761--ignore-all-space::
0ac7903e
WC
762 Ignore whitespace when comparing lines. This ignores
763 differences even if one line has whitespace where the other
8ebe185b
JN
764 line has none.
765
36617af7
AP
766--ignore-blank-lines::
767 Ignore changes whose lines are all blank.
768
296d4a94
MK
769-I<regex>::
770--ignore-matching-lines=<regex>::
771 Ignore changes whose all lines match <regex>. This option may
772 be specified more than once.
773
6d0e674a
RS
774--inter-hunk-context=<lines>::
775 Show the context between diff hunks, up to the specified number
776 of lines, thereby fusing hunks that are close to each other.
c4888677
VN
777 Defaults to `diff.interHunkContext` or 0 if the config option
778 is unset.
6d0e674a 779
14937c2c
RS
780-W::
781--function-context::
0cce88f1
PB
782 Show whole function as context lines for each change.
783 The function names are determined in the same way as
784 `git diff` works out patch hunk headers (see 'Defining a
785 custom hunk-header' in linkgit:gitattributes[5]).
14937c2c 786
d4cb003f 787ifndef::git-format-patch[]
939ca96b 788ifndef::git-log[]
41bbf9d5
AR
789--exit-code::
790 Make the program exit with codes similar to diff(1).
791 That is, it exits with 1 if there were differences and
792 0 means no differences.
793
2a18c266 794--quiet::
dce5ef14 795 Disable all output of the program. Implies `--exit-code`.
939ca96b 796endif::git-log[]
d4cb003f 797endif::git-format-patch[]
2a18c266 798
72909bef
JS
799--ext-diff::
800 Allow an external diff helper to be executed. If you set an
5162e697
DM
801 external diff driver with linkgit:gitattributes[5], you need
802 to use this option with linkgit:git-log[1] and friends.
72909bef
JS
803
804--no-ext-diff::
805 Disallow external diff drivers.
806
d28790dc
JK
807--textconv::
808--no-textconv::
809 Allow (or disallow) external text conversion filters to be run
810 when comparing binary files. See linkgit:gitattributes[5] for
811 details. Because textconv filters are typically a one-way
812 conversion, the resulting diff is suitable for human
813 consumption, but cannot be applied. For this reason, textconv
814 filters are enabled by default only for linkgit:git-diff[1] and
815 linkgit:git-log[1], but not for linkgit:git-format-patch[1] or
816 diff plumbing commands.
817
dd44d419
JL
818--ignore-submodules[=<when>]::
819 Ignore changes to submodules in the diff generation. <when> can be
b1d04bfc 820 either "none", "untracked", "dirty" or "all", which is the default.
aee9c7d6
JL
821 Using "none" will consider the submodule modified when it either contains
822 untracked or modified files or its HEAD differs from the commit recorded
823 in the superproject and can be used to override any settings of the
302ad7a9 824 'ignore' option in linkgit:git-config[1] or linkgit:gitmodules[5]. When
dd44d419
JL
825 "untracked" is used submodules are not considered dirty when they only
826 contain untracked content (but they are still scanned for modified
827 content). Using "dirty" ignores all changes to the work tree of submodules,
828 only changes to the commits stored in the superproject are shown (this was
829 the behavior until 1.7.0). Using "all" hides all changes to submodules.
50fd9bd8 830
eab9a40b
JS
831--src-prefix=<prefix>::
832 Show the given source prefix instead of "a/".
833
834--dst-prefix=<prefix>::
835 Show the given destination prefix instead of "b/".
836
837--no-prefix::
838 Do not show any source or destination prefix.
839
660e113c
JK
840--line-prefix=<prefix>::
841 Prepend an additional prefix to every line of output.
842
b42b4519
NTND
843--ita-invisible-in-index::
844 By default entries added by "git add -N" appear as an existing
845 empty file in "git diff" and a new file in "git diff --cached".
846 This option makes the entry appear as a new file in "git diff"
847 and non-existent in "git diff --cached". This option could be
848 reverted with `--ita-visible-in-index`. Both options are
849 experimental and could be removed in future.
850
8db9307c 851For more detailed explanation on these common options, see also
6998e4db 852linkgit:gitdiffcore[7].