1GIT-FORMAT-PATCH(1)               Git Manual               GIT-FORMAT-PATCH(1)
2
3
4

NAME

6       git-format-patch - Prepare patches for e-mail submission
7

SYNOPSIS

9           git-format-patch [-n | -k] [-o <dir> | --stdout] [--thread]
10                              [--attach[=<boundary>] | --inline[=<boundary>]]
11                              [-s | --signoff] [<common diff options>]
12                              [--start-number <n>] [--numbered-files]
13                              [--in-reply-to=Message-Id] [--suffix=.<sfx>]
14                              [--ignore-if-in-upstream]
15                              [--subject-prefix=Subject-Prefix]
16                              [ <since> | <revision range> ]
17

DESCRIPTION

19       Prepare each commit with its patch in one file per commit, formatted to
20       resemble UNIX mailbox format. The output of this command is convenient
21       for e-mail submission or for use with git-am(1).
22
23       There are two ways to specify which commits to operate on.
24
25
26        1.  A single commit, <since>, specifies that the commits leading to
27           the tip of the current branch that are not in the history that
28           leads to the <since> to be output.
29
30        2.  Generic <revision range> expression (see "SPECIFYING REVISIONS"
31           section in git-rev-parse(1)) means the commits in the specified
32           range.
33       A single commit, when interpreted as a <revision range> expression,
34       means "everything that leads to that commit", but if you write git
35       format-patch <commit>, the previous rule applies to that command line
36       and you do not get "everything since the beginning of the time". If you
37       want to format everything since project inception to one commit, say
38       "git format-patch --root <commit>" to make it clear that it is the
39       latter case.
40
41       By default, each output file is numbered sequentially from 1, and uses
42       the first line of the commit message (massaged for pathname safety) as
43       the filename. With the --numbered-files option, the output file names
44       will only be numbers, without the first line of the commit appended.
45       The names of the output files are printed to standard output, unless
46       the --stdout option is specified.
47
48       If -o is specified, output files are created in <dir>. Otherwise they
49       are created in the current working directory.
50
51       If -n is specified, instead of "[PATCH] Subject", the first line is
52       formatted as "[PATCH n/m] Subject".
53
54       If given --thread, git-format-patch will generate In-Reply-To and
55       References headers to make the second and subsequent patch mails appear
56       as replies to the first mail; this also generates a Message-Id header
57       to reference.
58

OPTIONS

60       -p
61           Generate patch (see section on generating patches)
62
63       -u
64           Synonym for "-p".
65
66       -U<n>
67           Shorthand for "--unified=<n>".
68
69       --unified=<n>
70           Generate diffs with <n> lines of context instead of the usual
71           three. Implies "-p".
72
73       --raw
74           Generate the raw format.
75
76       --patch-with-raw
77           Synonym for "-p --raw".
78
79       --stat[=width[,name-width]]
80           Generate a diffstat. You can override the default output width for
81           80-column terminal by "--stat=width". The width of the filename
82           part can be controlled by giving another width to it separated by a
83           comma.
84
85       --numstat
86           Similar to --stat, but shows number of added and deleted lines in
87           decimal notation and pathname without abbreviation, to make it more
88           machine friendly. For binary files, outputs two - instead of saying
89           0 0.
90
91       --shortstat
92           Output only the last line of the --stat format containing total
93           number of modified files, as well as number of added and deleted
94           lines.
95
96       --summary
97           Output a condensed summary of extended header information such as
98           creations, renames and mode changes.
99
100       --patch-with-stat
101           Synonym for "-p --stat".
102
103       -z
104           NUL-line termination on output. This affects the --raw output field
105           terminator. Also output from commands such as "git-log" will be
106           delimited with NUL between commits.
107
108       --name-only
109           Show only names of changed files.
110
111       --name-status
112           Show only names and status of changed files.
113
114       --color
115           Show colored diff.
116
117       --no-color
118           Turn off colored diff, even when the configuration file gives the
119           default to color output.
120
121       --color-words
122           Show colored word diff, i.e. color words which have changed.
123
124       --no-renames
125           Turn off rename detection, even when the configuration file gives
126           the default to do so.
127
128       --check
129           Warn if changes introduce trailing whitespace or an indent that
130           uses a space before a tab.
131
132       --full-index
133           Instead of the first handful characters, show full object name of
134           pre- and post-image blob on the "index" line when generating a
135           patch format output.
136
137       --binary
138           In addition to --full-index, output "binary diff" that can be
139           applied with "git apply".
140
141       --abbrev[=<n>]
142           Instead of showing the full 40-byte hexadecimal object name in
143           diff-raw format output and diff-tree header lines, show only
144           handful hexdigits prefix. This is independent of --full-index
145           option above, which controls the diff-patch output format. Non
146           default number of digits can be specified with --abbrev=<n>.
147
148       -B
149           Break complete rewrite changes into pairs of delete and create.
150
151       -M
152           Detect renames.
153
154       -C
155           Detect copies as well as renames. See also --find-copies-harder.
156
157       --diff-filter=[ACDMRTUXB*]
158           Select only files that are Added (A), Copied (C), Deleted (D),
159           Modified (M), Renamed (R), have their type (mode) changed (T), are
160           Unmerged (U), are Unknown (X), or have had their pairing Broken
161           (B). Any combination of the filter characters may be used. When *
162           (All-or-none) is added to the combination, all paths are selected
163           if there is any file that matches other criteria in the comparison;
164           if there is no file that matches other criteria, nothing is
165           selected.
166
167       --find-copies-harder
168           For performance reasons, by default, -C option finds copies only if
169           the original file of the copy was modified in the same changeset.
170           This flag makes the command inspect unmodified files as candidates
171           for the source of copy. This is a very expensive operation for
172           large projects, so use it with caution. Giving more than one -C
173           option has the same effect.
174
175       -l<num>
176           -M and -C options require O(n^2) processing time where n is the
177           number of potential rename/copy targets. This option prevents
178           rename/copy detection from running if the number of rename/copy
179           targets exceeds the specified number.
180
181       -S<string>
182           Look for differences that contain the change in <string>.
183
184       --pickaxe-all
185           When -S finds a change, show all the changes in that changeset, not
186           just the files that contain the change in <string>.
187
188       --pickaxe-regex
189           Make the <string> not a plain string but an extended POSIX regex to
190           match.
191
192       -O<orderfile>
193           Output the patch in the order specified in the <orderfile>, which
194           has one shell glob pattern per line.
195
196       -R
197           Swap two inputs; that is, show differences from index or on-disk
198           file to tree contents.
199
200       --text
201           Treat all files as text.
202
203       -a
204           Shorthand for "--text".
205
206       --ignore-space-at-eol
207           Ignore changes in white spaces at EOL.
208
209       --ignore-space-change
210           Ignore changes in amount of white space. This ignores white space
211           at line end, and consider all other sequences of one or more white
212           space characters to be equivalent.
213
214       -b
215           Shorthand for "--ignore-space-change".
216
217       --ignore-all-space
218           Ignore white space when comparing lines. This ignores difference
219           even if one line has white space where the other line has none.
220
221       -w
222           Shorthand for "--ignore-all-space".
223
224       --exit-code
225           Make the program exit with codes similar to diff(1). That is, it
226           exits with 1 if there were differences and 0 means no differences.
227
228       --quiet
229           Disable all output of the program. Implies --exit-code.
230
231       --ext-diff
232           Allow an external diff helper to be executed. If you set an
233           external diff driver with gitlink:gitattributes(5), you need to use
234           this option with gitlink:git-log(1) and friends.
235
236       --no-ext-diff
237           Disallow external diff drivers.
238       For more detailed explanation on these common options, see also
239       diffcore documentation[1].
240
241       -<n>
242           Limits the number of patches to prepare.
243
244       -o|--output-directory <dir>
245           Use <dir> to store the resulting files, instead of the current
246           working directory.
247
248       -n|--numbered
249           Name output in [PATCH n/m] format.
250
251       --start-number <n>
252           Start numbering the patches at <n> instead of 1.
253
254       --numbered-files
255           Output file names will be a simple number sequence without the
256           default first line of the commit appended. Mutually exclusive with
257           the --stdout option.
258
259       -k|--keep-subject
260           Do not strip/add [PATCH] from the first line of the commit log
261           message.
262
263       -s|--signoff
264           Add Signed-off-by: line to the commit message, using the committer
265           identity of yourself.
266
267       --stdout
268           Print all commits to the standard output in mbox format, instead of
269           creating a file for each one.
270
271       --attach[=<boundary>]
272           Create multipart/mixed attachment, the first part of which is the
273           commit message and the patch itself in the second part, with
274           "Content-Disposition: attachment".
275
276       --inline[=<boundary>]
277           Create multipart/mixed attachment, the first part of which is the
278           commit message and the patch itself in the second part, with
279           "Content-Disposition: inline".
280
281       --thread
282           Add In-Reply-To and References headers to make the second and
283           subsequent mails appear as replies to the first. Also generates the
284           Message-Id header to reference.
285
286       --in-reply-to=Message-Id
287           Make the first mail (or all the mails with --no-thread) appear as a
288           reply to the given Message-Id, which avoids breaking threads to
289           provide a new patch series.
290
291       --ignore-if-in-upstream
292           Do not include a patch that matches a commit in <until>..<since>.
293           This will examine all patches reachable from <since> but not from
294           <until> and compare them with the patches being generated, and any
295           patch that matches is ignored.
296
297       --subject-prefix=<Subject-Prefix>
298           Instead of the standard [PATCH] prefix in the subject line, instead
299           use [<Subject-Prefix>]. This allows for useful naming of a patch
300           series, and can be combined with the --numbered option.
301
302       --suffix=.<sfx>
303           Instead of using .patch as the suffix for generated filenames, use
304           specified suffix. A common alternative is --suffix=.txt.
305
306           Note that you would need to include the leading dot . if you want a
307           filename like 0001-description-of-my-change.patch, and the first
308           letter does not have to be a dot. Leaving it empty would not add
309           any suffix.
310

CONFIGURATION

312       You can specify extra mail header lines to be added to each message in
313       the repository configuration. You can also specify new defaults for the
314       subject prefix and file suffix.
315
316
317
318           [format]
319                   headers = "Organization: git-foo\n"
320                   subjectprefix = CHANGE
321                   suffix = .txt
322
323

EXAMPLES

325       git-format-patch -k --stdout R1..R2 | git-am -3 -k
326           Extract commits between revisions R1 and R2, and apply them on top
327           of the current branch using git-am to cherry-pick them.
328
329       git-format-patch origin
330           Extract all commits which are in the current branch but not in the
331           origin branch. For each commit a separate file is created in the
332           current directory.
333
334       git-format-patch --root origin
335           Extract all commits which that leads to origin since the inception
336           of the project.
337
338       git-format-patch -M -B origin
339           The same as the previous one. Additionally, it detects and handles
340           renames and complete rewrites intelligently to produce a renaming
341           patch. A renaming patch reduces the amount of text output, and
342           generally makes it easier to review it. Note that the "patch"
343           program does not understand renaming patches, so use it only when
344           you know the recipient uses git to apply your patch.
345
346       git-format-patch -3
347           Extract three topmost commits from the current branch and format
348           them as e-mailable patches.
349

SEE ALSO

351       git-am(1), git-send-email(1)
352

AUTHOR

354       Written by Junio C Hamano <junkio@cox.net>
355

DOCUMENTATION

357       Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
358

GIT

360       Part of the git(7) suite
361

NOTES

363        1. diffcore documentation
364           diffcore.html
365
366
367
368Git 1.5.3.3                       10/09/2007               GIT-FORMAT-PATCH(1)
Impressum