Merge branch 'tr/maint-1.6.1-doc-format-patch--root'
[alt-git.git] / Documentation / git-format-patch.txt
blobc105925df8f3e56c6d660a8f88fa5d7c2c935b92
1 git-format-patch(1)
2 ===================
4 NAME
5 ----
6 git-format-patch - Prepare patches for e-mail submission
9 SYNOPSIS
10 --------
11 [verse]
12 'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
13                    [--attach[=<boundary>] | --inline[=<boundary>] |
14                      [--no-attach]]
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]
21                    [--cc=<email>]
22                    [--cover-letter]
23                    [ <since> | <revision range> ]
25 DESCRIPTION
26 -----------
28 Prepare each commit with its patch in
29 one file per commit, formatted to resemble UNIX mailbox format.
30 The output of this command is convenient for e-mail submission or
31 for use with 'git-am'.
33 There are two ways to specify which commits to operate on.
35 1. 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.
39 2. Generic <revision range> expression (see "SPECIFYING
40    REVISIONS" section in linkgit:git-rev-parse[1]) means the
41    commits in the specified range.
43 The first rule takes precedence in the case of a single <commit>.  To
44 apply the second rule, i.e., format everything since the beginning of
45 history up until <commit>, use the '\--root' option: "git format-patch
46 \--root <commit>".  If you want to format only <commit> itself, you
47 can do this with "git format-patch -1 <commit>".
49 By default, each output file is numbered sequentially from 1, and uses the
50 first line of the commit message (massaged for pathname safety) as
51 the filename. With the --numbered-files option, the output file names
52 will only be numbers, without the first line of the commit appended.
53 The names of the output files are printed to standard
54 output, unless the --stdout option is specified.
56 If -o is specified, output files are created in <dir>.  Otherwise
57 they are created in the current working directory.
59 By default, the subject of a single patch is "[PATCH] First Line" and
60 the subject when multiple patches are output is "[PATCH n/m] First
61 Line". To force 1/1 to be added for a single patch, use -n.  To omit
62 patch numbers from the subject, use -N
64 If given --thread, 'git-format-patch' will generate In-Reply-To and
65 References headers to make the second and subsequent patch mails appear
66 as replies to the first mail; this also generates a Message-Id header to
67 reference.
69 OPTIONS
70 -------
71 :git-format-patch: 1
72 include::diff-options.txt[]
74 -<n>::
75         Limits the number of patches to prepare.
77 -o <dir>::
78 --output-directory <dir>::
79         Use <dir> to store the resulting files, instead of the
80         current working directory.
82 -n::
83 --numbered::
84         Name output in '[PATCH n/m]' format, even with a single patch.
86 -N::
87 --no-numbered::
88         Name output in '[PATCH]' format.
90 --start-number <n>::
91         Start numbering the patches at <n> instead of 1.
93 --numbered-files::
94         Output file names will be a simple number sequence
95         without the default first line of the commit appended.
97 -k::
98 --keep-subject::
99         Do not strip/add '[PATCH]' from the first line of the
100         commit log message.
102 -s::
103 --signoff::
104         Add `Signed-off-by:` line to the commit message, using
105         the committer identity of yourself.
107 --stdout::
108         Print all commits to the standard output in mbox format,
109         instead of creating a file for each one.
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".
116 --no-attach::
117         Disable the creation of an attachment, overriding the
118         configuration setting.
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".
125 --thread[=<style>]::
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.
130 The optional <style> argument can be either `shallow` or `deep`.
131 'Shallow' threading makes every mail a reply to the head of the
132 series, where the head is chosen from the cover letter, the
133 `\--in-reply-to`, and the first patch mail, in this order.  'Deep'
134 threading makes every mail a reply to the previous one.  If not
135 specified, defaults to the 'format.thread' configuration, or `shallow`
136 if that is not set.
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.
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.
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.
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.
160 --cover-letter::
161         In addition to the patches, generate a cover letter file
162         containing the shortlog and the overall diffstat.  You can
163         fill in a description in the file before sending it out.
165 --suffix=.<sfx>::
166         Instead of using `.patch` as the suffix for generated
167         filenames, use specified suffix.  A common alternative is
168         `--suffix=.txt`.
170 Note that you would need to include the leading dot `.` if you
171 want a filename like `0001-description-of-my-change.patch`, and
172 the first letter does not have to be a dot.  Leaving it empty would
173 not add any suffix.
175 --no-binary::
176         Don't output contents of changes in binary files, just take note
177         that they differ.  Note that this disable the patch to be properly
178         applied.  By default the contents of changes in those files are
179         encoded in the patch.
181 --root::
182         Treat the revision argument as a <revision range>, even if it
183         is just a single commit (that would normally be treated as a
184         <since>).  Note that root commits included in the specified
185         range are always formatted as creation patches, independently
186         of this flag.
188 CONFIGURATION
189 -------------
190 You can specify extra mail header lines to be added to each message
191 in the repository configuration, new defaults for the subject prefix
192 and file suffix, control attachements, and number patches when outputting
193 more than one.
195 ------------
196 [format]
197         headers = "Organization: git-foo\n"
198         subjectprefix = CHANGE
199         suffix = .txt
200         numbered = auto
201         cc = <email>
202         attach [ = mime-boundary-string ]
203 ------------
206 EXAMPLES
207 --------
209 * Extract commits between revisions R1 and R2, and apply them on top of
210 the current branch using 'git-am' to cherry-pick them:
212 ------------
213 $ git format-patch -k --stdout R1..R2 | git am -3 -k
214 ------------
216 * Extract all commits which are in the current branch but not in the
217 origin branch:
219 ------------
220 $ git format-patch origin
221 ------------
223 For each commit a separate file is created in the current directory.
225 * Extract all commits that lead to 'origin' since the inception of the
226 project:
228 ------------
229 $ git format-patch --root origin
230 ------------
232 * The same as the previous one:
234 ------------
235 $ git format-patch -M -B origin
236 ------------
238 Additionally, it detects and handles renames and complete rewrites
239 intelligently to produce a renaming patch.  A renaming patch reduces
240 the amount of text output, and generally makes it easier to review it.
241 Note that the "patch" program does not understand renaming patches, so
242 use it only when you know the recipient uses git to apply your patch.
244 * Extract three topmost commits from the current branch and format them
245 as e-mailable patches:
247 ------------
248 $ git format-patch -3
249 ------------
251 SEE ALSO
252 --------
253 linkgit:git-am[1], linkgit:git-send-email[1]
256 Author
257 ------
258 Written by Junio C Hamano <gitster@pobox.com>
260 Documentation
261 --------------
262 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
266 Part of the linkgit:git[1] suite