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