Merge branch 'bs/maint-1.6.0-tree-walk-prefix' into maint-1.6.1
[git/dscho.git] / Documentation / git-format-patch.txt
blob1f577b8016156871debcbb17fc32af9f7a6082f4
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                    [-s | --signoff] [<common diff options>]
15                    [-n | --numbered | -N | --no-numbered]
16                    [--start-number <n>] [--numbered-files]
17                    [--in-reply-to=Message-Id] [--suffix=.<sfx>]
18                    [--ignore-if-in-upstream]
19                    [--subject-prefix=Subject-Prefix]
20                    [--cc=<email>]
21                    [--cover-letter]
22                    [ <since> | <revision range> ]
24 DESCRIPTION
25 -----------
27 Prepare each commit with its patch in
28 one file per commit, formatted to resemble UNIX mailbox format.
29 The output of this command is convenient for e-mail submission or
30 for use with 'git-am'.
32 There are two ways to specify which commits to operate on.
34 1. A single commit, <since>, specifies that the commits leading
35    to the tip of the current branch that are not in the history
36    that leads to the <since> to be output.
38 2. Generic <revision range> expression (see "SPECIFYING
39    REVISIONS" section in linkgit:git-rev-parse[1]) means the
40    commits in the specified range.
42 The first rule takes precedence in the case of a single <commit>.  To
43 apply the second rule, i.e., format everything since the beginning of
44 history up until <commit>, use the '\--root' option: "git format-patch
45 \--root <commit>".  If you want to format only <commit> itself, you
46 can do this with "git format-patch -1 <commit>".
48 By default, each output file is numbered sequentially from 1, and uses the
49 first line of the commit message (massaged for pathname safety) as
50 the filename. With the --numbered-files option, the output file names
51 will only be numbers, without the first line of the commit appended.
52 The names of the output files are printed to standard
53 output, unless the --stdout option is specified.
55 If -o is specified, output files are created in <dir>.  Otherwise
56 they are created in the current working directory.
58 By default, the subject of a single patch is "[PATCH] First Line" and
59 the subject when multiple patches are output is "[PATCH n/m] First
60 Line". To force 1/1 to be added for a single patch, use -n.  To omit
61 patch numbers from the subject, use -N
63 If given --thread, 'git-format-patch' will generate In-Reply-To and
64 References headers to make the second and subsequent patch mails appear
65 as replies to the first mail; this also generates a Message-Id header to
66 reference.
68 OPTIONS
69 -------
70 :git-format-patch: 1
71 include::diff-options.txt[]
73 -<n>::
74         Limits the number of patches to prepare.
76 -o <dir>::
77 --output-directory <dir>::
78         Use <dir> to store the resulting files, instead of the
79         current working directory.
81 -n::
82 --numbered::
83         Name output in '[PATCH n/m]' format, even with a single patch.
85 -N::
86 --no-numbered::
87         Name output in '[PATCH]' format.
89 --start-number <n>::
90         Start numbering the patches at <n> instead of 1.
92 --numbered-files::
93         Output file names will be a simple number sequence
94         without the default first line of the commit appended.
95         Mutually exclusive with the --stdout option.
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 --inline[=<boundary>]::
117         Create multipart/mixed attachment, the first part of
118         which is the commit message and the patch itself in the
119         second part, with "Content-Disposition: inline".
121 --thread::
122         Add In-Reply-To and References headers to make the second and
123         subsequent mails appear as replies to the first.  Also generates
124         the Message-Id header to reference.
126 --in-reply-to=Message-Id::
127         Make the first mail (or all the mails with --no-thread) appear as a
128         reply to the given Message-Id, which avoids breaking threads to
129         provide a new patch series.
131 --ignore-if-in-upstream::
132         Do not include a patch that matches a commit in
133         <until>..<since>.  This will examine all patches reachable
134         from <since> but not from <until> and compare them with the
135         patches being generated, and any patch that matches is
136         ignored.
138 --subject-prefix=<Subject-Prefix>::
139         Instead of the standard '[PATCH]' prefix in the subject
140         line, instead use '[<Subject-Prefix>]'. This
141         allows for useful naming of a patch series, and can be
142         combined with the --numbered option.
144 --cc=<email>::
145         Add a "Cc:" header to the email headers. This is in addition
146         to any configured headers, and may be used multiple times.
148 --cover-letter::
149         In addition to the patches, generate a cover letter file
150         containing the shortlog and the overall diffstat.  You can
151         fill in a description in the file before sending it out.
153 --suffix=.<sfx>::
154         Instead of using `.patch` as the suffix for generated
155         filenames, use specified suffix.  A common alternative is
156         `--suffix=.txt`.
158 Note that you would need to include the leading dot `.` if you
159 want a filename like `0001-description-of-my-change.patch`, and
160 the first letter does not have to be a dot.  Leaving it empty would
161 not add any suffix.
163 --no-binary::
164         Don't output contents of changes in binary files, just take note
165         that they differ.  Note that this disable the patch to be properly
166         applied.  By default the contents of changes in those files are
167         encoded in the patch.
169 --root::
170         Treat the revision argument as a <revision range>, even if it
171         is just a single commit (that would normally be treated as a
172         <since>).  Note that root commits included in the specified
173         range are always formatted as creation patches, independently
174         of this flag.
176 CONFIGURATION
177 -------------
178 You can specify extra mail header lines to be added to each message
179 in the repository configuration, new defaults for the subject prefix
180 and file suffix, and number patches when outputting more than one.
182 ------------
183 [format]
184         headers = "Organization: git-foo\n"
185         subjectprefix = CHANGE
186         suffix = .txt
187         numbered = auto
188         cc = <email>
189 ------------
192 EXAMPLES
193 --------
195 * Extract commits between revisions R1 and R2, and apply them on top of
196 the current branch using 'git-am' to cherry-pick them:
198 ------------
199 $ git format-patch -k --stdout R1..R2 | git am -3 -k
200 ------------
202 * Extract all commits which are in the current branch but not in the
203 origin branch:
205 ------------
206 $ git format-patch origin
207 ------------
209 For each commit a separate file is created in the current directory.
211 * Extract all commits that lead to 'origin' since the inception of the
212 project:
214 ------------
215 $ git format-patch --root origin
216 ------------
218 * The same as the previous one:
220 ------------
221 $ git format-patch -M -B origin
222 ------------
224 Additionally, it detects and handles renames and complete rewrites
225 intelligently to produce a renaming patch.  A renaming patch reduces
226 the amount of text output, and generally makes it easier to review it.
227 Note that the "patch" program does not understand renaming patches, so
228 use it only when you know the recipient uses git to apply your patch.
230 * Extract three topmost commits from the current branch and format them
231 as e-mailable patches:
233 ------------
234 $ git format-patch -3
235 ------------
237 SEE ALSO
238 --------
239 linkgit:git-am[1], linkgit:git-send-email[1]
242 Author
243 ------
244 Written by Junio C Hamano <gitster@pobox.com>
246 Documentation
247 --------------
248 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
252 Part of the linkgit:git[1] suite