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