Merge branch 'maint'
[git/git.git] / Documentation / git-format-patch.txt
CommitLineData
215a7ad1
JH
1git-format-patch(1)
2===================
7fc9d69f
JH
3
4NAME
5----
7bd7f280 6git-format-patch - Prepare patches for e-mail submission
7fc9d69f
JH
7
8
9SYNOPSIS
10--------
353ce815 11[verse]
b1889c36 12'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
0db5260b
JW
13 [--attach[=<boundary>] | --inline[=<boundary>] |
14 [--no-attach]]
a5a27c79
DB
15 [-s | --signoff] [<common diff options>]
16 [-n | --numbered | -N | --no-numbered]
17 [--start-number <n>] [--numbered-files]
18 [--in-reply-to=Message-Id] [--suffix=.<sfx>]
19 [--ignore-if-in-upstream]
20 [--subject-prefix=Subject-Prefix]
736cc67d 21 [--cc=<email>]
a5a27c79 22 [--cover-letter]
8a1d076e 23 [ <since> | <revision range> ]
7fc9d69f
JH
24
25DESCRIPTION
26-----------
2052d146 27
8a1d076e 28Prepare each commit with its patch in
2052d146 29one file per commit, formatted to resemble UNIX mailbox format.
2052d146 30The output of this command is convenient for e-mail submission or
ba020ef5 31for use with 'git-am'.
35ef3a4c 32
8a1d076e
JH
33There are two ways to specify which commits to operate on.
34
351. A single commit, <since>, specifies that the commits leading
36 to the tip of the current branch that are not in the history
37 that leads to the <since> to be output.
38
392. Generic <revision range> expression (see "SPECIFYING
5162e697 40 REVISIONS" section in linkgit:git-rev-parse[1]) means the
2f6a3823
JH
41 commits in the specified range.
42
43A single commit, when interpreted as a <revision range>
44expression, means "everything that leads to that commit", but
45if you write 'git format-patch <commit>', the previous rule
46applies to that command line and you do not get "everything
47since the beginning of the time". If you want to format
48everything since project inception to one commit, say "git
49format-patch \--root <commit>" to make it clear that it is the
16088d88
JH
50latter case. If you want to format a single commit, you can do
51this with "git format-patch -1 <commit>".
8a1d076e 52
e6ff0f42 53By default, each output file is numbered sequentially from 1, and uses the
2052d146 54first line of the commit message (massaged for pathname safety) as
e6ff0f42
JL
55the filename. With the --numbered-files option, the output file names
56will only be numbers, without the first line of the commit appended.
57The names of the output files are printed to standard
2052d146 58output, unless the --stdout option is specified.
66f04f38 59
2052d146
DS
60If -o is specified, output files are created in <dir>. Otherwise
61they are created in the current working directory.
35ef3a4c 62
a567fdcb
BG
63By default, the subject of a single patch is "[PATCH] First Line" and
64the subject when multiple patches are output is "[PATCH n/m] First
65Line". To force 1/1 to be added for a single patch, use -n. To omit
66patch numbers from the subject, use -N
35ef3a4c 67
ba020ef5 68If given --thread, 'git-format-patch' will generate In-Reply-To and
cc35de84
JT
69References headers to make the second and subsequent patch mails appear
70as replies to the first mail; this also generates a Message-Id header to
71reference.
7fc9d69f
JH
72
73OPTIONS
74-------
c1a95fa6 75:git-format-patch: 1
b8105375
BG
76include::diff-options.txt[]
77
ed5f07a6
MV
78-<n>::
79 Limits the number of patches to prepare.
80
3240240f
SB
81-o <dir>::
82--output-directory <dir>::
35ef3a4c 83 Use <dir> to store the resulting files, instead of the
efd02016 84 current working directory.
35ef3a4c 85
3240240f
SB
86-n::
87--numbered::
a567fdcb 88 Name output in '[PATCH n/m]' format, even with a single patch.
35ef3a4c 89
3240240f
SB
90-N::
91--no-numbered::
49604a4d
BG
92 Name output in '[PATCH]' format.
93
2052d146
DS
94--start-number <n>::
95 Start numbering the patches at <n> instead of 1.
96
e6ff0f42
JL
97--numbered-files::
98 Output file names will be a simple number sequence
99 without the default first line of the commit appended.
e6ff0f42 100
3240240f
SB
101-k::
102--keep-subject::
35ef3a4c
JH
103 Do not strip/add '[PATCH]' from the first line of the
104 commit log message.
105
3240240f
SB
106-s::
107--signoff::
6f855371
NW
108 Add `Signed-off-by:` line to the commit message, using
109 the committer identity of yourself.
110
54ba6013 111--stdout::
2052d146
DS
112 Print all commits to the standard output in mbox format,
113 instead of creating a file for each one.
7fc9d69f 114
c112f689
JS
115--attach[=<boundary>]::
116 Create multipart/mixed attachment, the first part of
117 which is the commit message and the patch itself in the
118 second part, with "Content-Disposition: attachment".
119
0db5260b
JW
120--no-attach::
121 Disable the creation of an attachment, overriding the
122 configuration setting.
123
c112f689
JS
124--inline[=<boundary>]::
125 Create multipart/mixed attachment, the first part of
126 which is the commit message and the patch itself in the
127 second part, with "Content-Disposition: inline".
a15a44ef 128
30984ed2 129--thread[=<style>]::
cc35de84
JT
130 Add In-Reply-To and References headers to make the second and
131 subsequent mails appear as replies to the first. Also generates
132 the Message-Id header to reference.
30984ed2
TR
133+
134The optional <style> argument can be either `shallow` or `deep`.
135'Shallow' threading makes every mail a reply to the head of the
136series, where the head is chosen from the cover letter, the
137`\--in-reply-to`, and the first patch mail, in this order. 'Deep'
138threading makes every mail a reply to the previous one. If not
139specified, defaults to the 'format.thread' configuration, or `shallow`
140if that is not set.
28ffb898 141
da56645d
JT
142--in-reply-to=Message-Id::
143 Make the first mail (or all the mails with --no-thread) appear as a
144 reply to the given Message-Id, which avoids breaking threads to
145 provide a new patch series.
146
cc75ad67
DK
147--ignore-if-in-upstream::
148 Do not include a patch that matches a commit in
149 <until>..<since>. This will examine all patches reachable
150 from <since> but not from <until> and compare them with the
151 patches being generated, and any patch that matches is
152 ignored.
153
2d9e4a47
RJ
154--subject-prefix=<Subject-Prefix>::
155 Instead of the standard '[PATCH]' prefix in the subject
156 line, instead use '[<Subject-Prefix>]'. This
157 allows for useful naming of a patch series, and can be
158 combined with the --numbered option.
159
736cc67d
DB
160--cc=<email>::
161 Add a "Cc:" header to the email headers. This is in addition
162 to any configured headers, and may be used multiple times.
163
a5a27c79 164--cover-letter::
f4912391
MM
165 In addition to the patches, generate a cover letter file
166 containing the shortlog and the overall diffstat. You can
167 fill in a description in the file before sending it out.
a5a27c79 168
03eeaeae 169--suffix=.<sfx>::
917a8f89 170 Instead of using `.patch` as the suffix for generated
02783075 171 filenames, use specified suffix. A common alternative is
917a8f89 172 `--suffix=.txt`.
03eeaeae
JH
173+
174Note that you would need to include the leading dot `.` if you
175want a filename like `0001-description-of-my-change.patch`, and
176the first letter does not have to be a dot. Leaving it empty would
177not add any suffix.
178
37c22a4b
CMOF
179--no-binary::
180 Don't output contents of changes in binary files, just take note
181 that they differ. Note that this disable the patch to be properly
182 applied. By default the contents of changes in those files are
183 encoded in the patch.
184
96ce6d26
MM
185CONFIGURATION
186-------------
49604a4d
BG
187You can specify extra mail header lines to be added to each message
188in the repository configuration, new defaults for the subject prefix
0db5260b
JW
189and file suffix, control attachements, and number patches when outputting
190more than one.
96ce6d26 191
917a8f89 192------------
96ce6d26 193[format]
7f9d77f2
JN
194 headers = "Organization: git-foo\n"
195 subjectprefix = CHANGE
196 suffix = .txt
197 numbered = auto
fe8928e6 198 cc = <email>
0db5260b 199 attach [ = mime-boundary-string ]
917a8f89 200------------
03eeaeae 201
96ce6d26 202
28ffb898
JH
203EXAMPLES
204--------
205
921177f5 206* Extract commits between revisions R1 and R2, and apply them on top of
ba020ef5 207the current branch using 'git-am' to cherry-pick them:
921177f5
CC
208+
209------------
467c0197 210$ git format-patch -k --stdout R1..R2 | git am -3 -k
921177f5
CC
211------------
212
213* Extract all commits which are in the current branch but not in the
214origin branch:
215+
216------------
217$ git format-patch origin
218------------
219+
220For each commit a separate file is created in the current directory.
221
222* Extract all commits that lead to 'origin' since the inception of the
223project:
224+
225------------
9c67c757 226$ git format-patch --root origin
921177f5
CC
227------------
228
229* The same as the previous one:
230+
231------------
232$ git format-patch -M -B origin
233------------
234+
235Additionally, it detects and handles renames and complete rewrites
236intelligently to produce a renaming patch. A renaming patch reduces
237the amount of text output, and generally makes it easier to review it.
238Note that the "patch" program does not understand renaming patches, so
239use it only when you know the recipient uses git to apply your patch.
240
241* Extract three topmost commits from the current branch and format them
242as e-mailable patches:
243+
244------------
245$ git format-patch -3
246------------
28ffb898 247
56ae8df5 248SEE ALSO
28ffb898 249--------
5162e697 250linkgit:git-am[1], linkgit:git-send-email[1]
28ffb898
JH
251
252
7fc9d69f
JH
253Author
254------
59eb68aa 255Written by Junio C Hamano <gitster@pobox.com>
7fc9d69f
JH
256
257Documentation
258--------------
259Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
260
261GIT
262---
9e1f0a85 263Part of the linkgit:git[1] suite