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