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