]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/diff-options.txt
format-patch documentation: Fix formatting
[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::
02bc5b03 17 Generate plain patches without any diffstats.
c1a95fa6
SO
18endif::git-format-patch[]
19
20ifndef::git-format-patch[]
dda2d79a 21-p::
a9e67c8c 22-u::
c1a95fa6
SO
23 Generate patch (see section on generating patches).
24 {git-diff? This is the default.}
25endif::git-format-patch[]
dda2d79a 26
4eb99473 27-U<n>::
4eb99473
RR
28--unified=<n>::
29 Generate diffs with <n> lines of context instead of
02bc5b03
BG
30 the usual three.
31ifndef::git-format-patch[]
dce5ef14 32 Implies `-p`.
02bc5b03 33endif::git-format-patch[]
4eb99473 34
d4cb003f 35ifndef::git-format-patch[]
b5376648
JH
36--raw::
37 Generate the raw format.
c1a95fa6 38 {git-diff-core? This is the default.}
d4cb003f 39endif::git-format-patch[]
b5376648 40
02bc5b03 41ifndef::git-format-patch[]
5c91da25 42--patch-with-raw::
dce5ef14 43 Synonym for `-p --raw`.
02bc5b03 44endif::git-format-patch[]
5c91da25 45
ec74042d 46--patience::
34292bdd
JS
47 Generate a diff using the "patience diff" algorithm.
48
5c5b2ea9
LT
49--stat[=width[,name-width]]::
50 Generate a diffstat. You can override the default
dce5ef14 51 output width for 80-column terminal by `--stat=width`.
5c5b2ea9
LT
52 The width of the filename part can be controlled by
53 giving another width to it separated by a comma.
d75f7952 54
74e2abe5 55--numstat::
dce5ef14 56 Similar to `\--stat`, but shows number of added and
74e2abe5 57 deleted lines in decimal notation and pathname without
2f89543e
JH
58 abbreviation, to make it more machine friendly. For
59 binary files, outputs two `-` instead of saying
60 `0 0`.
74e2abe5 61
ebd124c6 62--shortstat::
dce5ef14 63 Output only the last line of the `--stat` format containing total
ebd124c6
NP
64 number of modified files, as well as number of added and deleted
65 lines.
66
37152d83 67--dirstat[=limit]::
62e00b0a
HO
68 Output the distribution of relative amount of changes (number of lines added or
69 removed) for each sub-directory. Directories with changes below
70 a cut-off percent (3% by default) are not shown. The cut-off percent
dce5ef14
BG
71 can be set with `--dirstat=limit`. Changes in a child directory is not
72 counted for the parent directory, unless `--cumulative` is used.
37152d83 73
fd33777b 74--dirstat-by-file[=limit]::
dce5ef14 75 Same as `--dirstat`, but counts changed files instead of lines.
fd33777b 76
4bbd261b
SE
77--summary::
78 Output a condensed summary of extended header information
79 such as creations, renames and mode changes.
80
02bc5b03 81ifndef::git-format-patch[]
29353273 82--patch-with-stat::
dce5ef14 83 Synonym for `-p --stat`.
02bc5b03 84endif::git-format-patch[]
29353273 85
d4cb003f 86ifndef::git-format-patch[]
dda2d79a 87-z::
dce5ef14 88 NUL-line termination on output. This affects the `--raw`
654a7ccc 89 output field terminator. Also output from commands such
dce5ef14 90 as `git-log` will be delimited with NUL between commits.
dda2d79a
JH
91
92--name-only::
93 Show only names of changed files.
94
946f5f7c 95--name-status::
a6f47b2b
MV
96 Show only names and status of changed files. See the description
97 of the `--diff-filter` option on what the status letters mean.
dda2d79a 98
b5376648
JH
99--color::
100 Show colored diff.
101
102--no-color::
103 Turn off colored diff, even when the configuration file
104 gives the default to color output.
105
c4b252c3
TR
106--color-words[=<regex>]::
107 Show colored word diff, i.e., color words which have changed.
108 By default, words are separated by whitespace.
2b6a5417 109+
c4b252c3
TR
110When a <regex> is specified, every non-overlapping match of the
111<regex> is considered a word. Anything between these matches is
112considered whitespace and ignored(!) for the purposes of finding
113differences. You may want to append `|[^[:space:]]` to your regular
114expression to make sure that it matches all non-whitespace characters.
115A match that contains a newline is silently truncated(!) at the
116newline.
80c49c3d 117+
98a4d87b
BSSJ
118The regex can also be set via a diff driver or configuration option, see
119linkgit:gitattributes[1] or linkgit:git-config[1]. Giving it explicitly
120overrides any diff driver or configuration setting. Diff drivers
121override configuration settings.
d4cb003f 122endif::git-format-patch[]
f59a59e2 123
b5376648
JH
124--no-renames::
125 Turn off rename detection, even when the configuration
126 file gives the default to do so.
127
02bc5b03 128ifndef::git-format-patch[]
16507fcf
BL
129--check::
130 Warn if changes introduce trailing whitespace
62c64895
WC
131 or an indent that uses a space before a tab. Exits with
132 non-zero status if problems are found. Not compatible with
133 --exit-code.
02bc5b03 134endif::git-format-patch[]
16507fcf 135
80b1e511 136--full-index::
6457e58c
JM
137 Instead of the first handful of characters, show the full
138 pre- and post-image blob object names on the "index"
139 line when generating patch format output.
b5376648
JH
140
141--binary::
dce5ef14
BG
142 In addition to `--full-index`, output a binary diff that
143 can be applied with `git-apply`.
80b1e511 144
913419fc 145--abbrev[=<n>]::
47dd0d59
JH
146 Instead of showing the full 40-byte hexadecimal object
147 name in diff-raw format output and diff-tree header
323b9db8 148 lines, show only a partial prefix. This is
dce5ef14 149 independent of the `--full-index` option above, which controls
913419fc 150 the diff-patch output format. Non default number of
dce5ef14 151 digits can be specified with `--abbrev=<n>`.
47dd0d59 152
dda2d79a
JH
153-B::
154 Break complete rewrite changes into pairs of delete and create.
155
156-M::
157 Detect renames.
158
159-C::
ca6c0970 160 Detect copies as well as renames. See also `--find-copies-harder`.
dda2d79a 161
d4cb003f 162ifndef::git-format-patch[]
147cf317
JL
163--diff-filter=[ACDMRTUXB*]::
164 Select only files that are Added (`A`), Copied (`C`),
165 Deleted (`D`), Modified (`M`), Renamed (`R`), have their
f07c3c53
JH
166 type (i.e. regular file, symlink, submodule, ...) changed (`T`),
167 are Unmerged (`U`), are
147cf317
JL
168 Unknown (`X`), or have had their pairing Broken (`B`).
169 Any combination of the filter characters may be used.
170 When `*` (All-or-none) is added to the combination, all
171 paths are selected if there is any file that matches
172 other criteria in the comparison; if there is no file
173 that matches other criteria, nothing is selected.
d4cb003f 174endif::git-format-patch[]
147cf317 175
dda2d79a 176--find-copies-harder::
ca6c0970 177 For performance reasons, by default, `-C` option finds copies only
a6080a0a 178 if the original file of the copy was modified in the same
f73ae1fc 179 changeset. This flag makes the command
dda2d79a
JH
180 inspect unmodified files as candidates for the source of
181 copy. This is a very expensive operation for large
ca6c0970
JS
182 projects, so use it with caution. Giving more than one
183 `-C` option has the same effect.
dda2d79a 184
8082d8d3 185-l<num>::
dce5ef14 186 The `-M` and `-C` options require O(n^2) processing time where n
f73ae1fc 187 is the number of potential rename/copy targets. This
8082d8d3 188 option prevents rename/copy detection from running if
f73ae1fc 189 the number of rename/copy targets exceeds the specified
8082d8d3
JH
190 number.
191
d4cb003f 192ifndef::git-format-patch[]
dda2d79a 193-S<string>::
821d56aa
JK
194 Look for differences that introduce or remove an instance of
195 <string>. Note that this is different than the string simply
196 appearing in diff output; see the 'pickaxe' entry in
197 linkgit:gitdiffcore[7] for more details.
dda2d79a
JH
198
199--pickaxe-all::
dce5ef14 200 When `-S` finds a change, show all the changes in that
f73ae1fc 201 changeset, not just the files that contain the change
dda2d79a
JH
202 in <string>.
203
d01d8c67
PB
204--pickaxe-regex::
205 Make the <string> not a plain string but an extended POSIX
206 regex to match.
d4cb003f 207endif::git-format-patch[]
d01d8c67 208
dda2d79a
JH
209-O<orderfile>::
210 Output the patch in the order specified in the
211 <orderfile>, which has one shell glob pattern per line.
212
d4cb003f 213ifndef::git-format-patch[]
dda2d79a 214-R::
5f3aa197 215 Swap two inputs; that is, show differences from index or
dda2d79a
JH
216 on-disk file to tree contents.
217
c0cb4a06 218--relative[=<path>]::
cd676a51
JH
219 When run from a subdirectory of the project, it can be
220 told to exclude changes outside the directory and show
c0cb4a06
JH
221 pathnames relative to it with this option. When you are
222 not in a subdirectory (e.g. in a bare repository), you
223 can name which subdirectory to make the output relative
224 to by giving a <path> as an argument.
d4cb003f 225endif::git-format-patch[]
cd676a51 226
a9e67c8c 227-a::
d507bb15
SF
228--text::
229 Treat all files as text.
230
a44a0c99 231--ignore-space-at-eol::
0ac7903e 232 Ignore changes in whitespace at EOL.
a44a0c99 233
a9e67c8c 234-b::
8ebe185b 235--ignore-space-change::
0ac7903e
WC
236 Ignore changes in amount of whitespace. This ignores whitespace
237 at line end, and considers all other sequences of one or
238 more whitespace characters to be equivalent.
8ebe185b 239
a9e67c8c 240-w::
8ebe185b 241--ignore-all-space::
0ac7903e
WC
242 Ignore whitespace when comparing lines. This ignores
243 differences even if one line has whitespace where the other
8ebe185b
JN
244 line has none.
245
6d0e674a
RS
246--inter-hunk-context=<lines>::
247 Show the context between diff hunks, up to the specified number
248 of lines, thereby fusing hunks that are close to each other.
249
d4cb003f 250ifndef::git-format-patch[]
41bbf9d5
AR
251--exit-code::
252 Make the program exit with codes similar to diff(1).
253 That is, it exits with 1 if there were differences and
254 0 means no differences.
255
2a18c266 256--quiet::
dce5ef14 257 Disable all output of the program. Implies `--exit-code`.
d4cb003f 258endif::git-format-patch[]
2a18c266 259
72909bef
JS
260--ext-diff::
261 Allow an external diff helper to be executed. If you set an
5162e697
DM
262 external diff driver with linkgit:gitattributes[5], you need
263 to use this option with linkgit:git-log[1] and friends.
72909bef
JS
264
265--no-ext-diff::
266 Disallow external diff drivers.
267
50fd9bd8
JS
268--ignore-submodules::
269 Ignore changes to submodules in the diff generation.
270
eab9a40b
JS
271--src-prefix=<prefix>::
272 Show the given source prefix instead of "a/".
273
274--dst-prefix=<prefix>::
275 Show the given destination prefix instead of "b/".
276
277--no-prefix::
278 Do not show any source or destination prefix.
279
8db9307c 280For more detailed explanation on these common options, see also
6998e4db 281linkgit:gitdiffcore[7].