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