]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - Documentation/diff-options.txt
format-patch: Always generate a patch
[thirdparty/git.git] / Documentation / diff-options.txt
... / ...
CommitLineData
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 Generate plain patches without any diffstats.
18endif::git-format-patch[]
19
20ifndef::git-format-patch[]
21-p::
22-u::
23 Generate patch (see section on generating patches).
24 {git-diff? This is the default.}
25endif::git-format-patch[]
26
27-U<n>::
28--unified=<n>::
29 Generate diffs with <n> lines of context instead of
30 the usual three.
31ifndef::git-format-patch[]
32 Implies "-p".
33endif::git-format-patch[]
34
35--raw::
36 Generate the raw format.
37 {git-diff-core? This is the default.}
38
39ifndef::git-format-patch[]
40--patch-with-raw::
41 Synonym for "-p --raw".
42endif::git-format-patch[]
43
44--patience::
45 Generate a diff using the "patience diff" algorithm.
46
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.
52
53--numstat::
54 Similar to \--stat, but shows number of added and
55 deleted lines in decimal notation and pathname without
56 abbreviation, to make it more machine friendly. For
57 binary files, outputs two `-` instead of saying
58 `0 0`.
59
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
65--dirstat[=limit]::
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.
71
72--dirstat-by-file[=limit]::
73 Same as --dirstat, but counts changed files instead of lines.
74
75--summary::
76 Output a condensed summary of extended header information
77 such as creations, renames and mode changes.
78
79ifndef::git-format-patch[]
80--patch-with-stat::
81 Synonym for "-p --stat".
82endif::git-format-patch[]
83
84-z::
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.
88
89ifndef::git-format-patch[]
90--name-only::
91 Show only names of changed files.
92
93--name-status::
94 Show only names and status of changed files. See the description
95 of the `--diff-filter` option on what the status letters mean.
96endif::git-format-patch[]
97
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
105--color-words[=<regex>]::
106 Show colored word diff, i.e., color words which have changed.
107 By default, words are separated by whitespace.
108+
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.
116+
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.
121
122--no-renames::
123 Turn off rename detection, even when the configuration
124 file gives the default to do so.
125
126ifndef::git-format-patch[]
127--check::
128 Warn if changes introduce trailing whitespace
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.
132endif::git-format-patch[]
133
134--full-index::
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.
138
139--binary::
140 In addition to --full-index, output "binary diff" that
141 can be applied with "git apply".
142
143--abbrev[=<n>]::
144 Instead of showing the full 40-byte hexadecimal object
145 name in diff-raw format output and diff-tree header
146 lines, show only a partial prefix. This is
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>.
150
151-B::
152 Break complete rewrite changes into pairs of delete and create.
153
154-M::
155 Detect renames.
156
157-C::
158 Detect copies as well as renames. See also `--find-copies-harder`.
159
160--diff-filter=[ACDMRTUXB*]::
161 Select only files that are Added (`A`), Copied (`C`),
162 Deleted (`D`), Modified (`M`), Renamed (`R`), have their
163 type (i.e. regular file, symlink, submodule, ...) changed (`T`),
164 are Unmerged (`U`), are
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
172--find-copies-harder::
173 For performance reasons, by default, `-C` option finds copies only
174 if the original file of the copy was modified in the same
175 changeset. This flag makes the command
176 inspect unmodified files as candidates for the source of
177 copy. This is a very expensive operation for large
178 projects, so use it with caution. Giving more than one
179 `-C` option has the same effect.
180
181-l<num>::
182 -M and -C options require O(n^2) processing time where n
183 is the number of potential rename/copy targets. This
184 option prevents rename/copy detection from running if
185 the number of rename/copy targets exceeds the specified
186 number.
187
188-S<string>::
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.
193
194--pickaxe-all::
195 When -S finds a change, show all the changes in that
196 changeset, not just the files that contain the change
197 in <string>.
198
199--pickaxe-regex::
200 Make the <string> not a plain string but an extended POSIX
201 regex to match.
202
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::
208 Swap two inputs; that is, show differences from index or
209 on-disk file to tree contents.
210
211--relative[=<path>]::
212 When run from a subdirectory of the project, it can be
213 told to exclude changes outside the directory and show
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.
218
219-a::
220--text::
221 Treat all files as text.
222
223--ignore-space-at-eol::
224 Ignore changes in whitespace at EOL.
225
226-b::
227--ignore-space-change::
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.
231
232-w::
233--ignore-all-space::
234 Ignore whitespace when comparing lines. This ignores
235 differences even if one line has whitespace where the other
236 line has none.
237
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
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
247--quiet::
248 Disable all output of the program. Implies --exit-code.
249
250--ext-diff::
251 Allow an external diff helper to be executed. If you set an
252 external diff driver with linkgit:gitattributes[5], you need
253 to use this option with linkgit:git-log[1] and friends.
254
255--no-ext-diff::
256 Disallow external diff drivers.
257
258--ignore-submodules::
259 Ignore changes to submodules in the diff generation.
260
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
270For more detailed explanation on these common options, see also
271linkgit:gitdiffcore[7].