]> git.ipfire.org Git - thirdparty/git.git/blob - Documentation/git-format-patch.txt
Manual subsection to refer to other pages is SEE ALSO
[thirdparty/git.git] / Documentation / git-format-patch.txt
1 git-format-patch(1)
2 ===================
3
4 NAME
5 ----
6 git-format-patch - Prepare patches for e-mail submission
7
8
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> ]
23
24 DESCRIPTION
25 -----------
26
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 linkgit:git-am[1].
31
32 There are two ways to specify which commits to operate on.
33
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.
37
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.
41
42 A single commit, when interpreted as a <revision range>
43 expression, means "everything that leads to that commit", but
44 if you write 'git format-patch <commit>', the previous rule
45 applies to that command line and you do not get "everything
46 since the beginning of the time". If you want to format
47 everything since project inception to one commit, say "git
48 format-patch \--root <commit>" to make it clear that it is the
49 latter case.
50
51 By default, each output file is numbered sequentially from 1, and uses the
52 first line of the commit message (massaged for pathname safety) as
53 the filename. With the --numbered-files option, the output file names
54 will only be numbers, without the first line of the commit appended.
55 The names of the output files are printed to standard
56 output, unless the --stdout option is specified.
57
58 If -o is specified, output files are created in <dir>. Otherwise
59 they are created in the current working directory.
60
61 If -n is specified, instead of "[PATCH] Subject", the first line
62 is formatted as "[PATCH n/m] Subject".
63
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.
68
69 OPTIONS
70 -------
71 :git-format-patch: 1
72 include::diff-options.txt[]
73
74 -<n>::
75 Limits the number of patches to prepare.
76
77 -o|--output-directory <dir>::
78 Use <dir> to store the resulting files, instead of the
79 current working directory.
80
81 -n|--numbered::
82 Name output in '[PATCH n/m]' format.
83
84 -N|--no-numbered::
85 Name output in '[PATCH]' format.
86
87 --start-number <n>::
88 Start numbering the patches at <n> instead of 1.
89
90 --numbered-files::
91 Output file names will be a simple number sequence
92 without the default first line of the commit appended.
93 Mutually exclusive with the --stdout option.
94
95 -k|--keep-subject::
96 Do not strip/add '[PATCH]' from the first line of the
97 commit log message.
98
99 -s|--signoff::
100 Add `Signed-off-by:` line to the commit message, using
101 the committer identity of yourself.
102
103 --stdout::
104 Print all commits to the standard output in mbox format,
105 instead of creating a file for each one.
106
107 --attach[=<boundary>]::
108 Create multipart/mixed attachment, the first part of
109 which is the commit message and the patch itself in the
110 second part, with "Content-Disposition: attachment".
111
112 --inline[=<boundary>]::
113 Create multipart/mixed attachment, the first part of
114 which is the commit message and the patch itself in the
115 second part, with "Content-Disposition: inline".
116
117 --thread::
118 Add In-Reply-To and References headers to make the second and
119 subsequent mails appear as replies to the first. Also generates
120 the Message-Id header to reference.
121
122 --in-reply-to=Message-Id::
123 Make the first mail (or all the mails with --no-thread) appear as a
124 reply to the given Message-Id, which avoids breaking threads to
125 provide a new patch series.
126
127 --ignore-if-in-upstream::
128 Do not include a patch that matches a commit in
129 <until>..<since>. This will examine all patches reachable
130 from <since> but not from <until> and compare them with the
131 patches being generated, and any patch that matches is
132 ignored.
133
134 --subject-prefix=<Subject-Prefix>::
135 Instead of the standard '[PATCH]' prefix in the subject
136 line, instead use '[<Subject-Prefix>]'. This
137 allows for useful naming of a patch series, and can be
138 combined with the --numbered option.
139
140 --cc=<email>::
141 Add a "Cc:" header to the email headers. This is in addition
142 to any configured headers, and may be used multiple times.
143
144 --cover-letter::
145 Generate a cover letter template. You still have to fill in
146 a description, but the shortlog and the diffstat will be
147 generated for you.
148
149 --suffix=.<sfx>::
150 Instead of using `.patch` as the suffix for generated
151 filenames, use specified suffix. A common alternative is
152 `--suffix=.txt`.
153 +
154 Note that you would need to include the leading dot `.` if you
155 want a filename like `0001-description-of-my-change.patch`, and
156 the first letter does not have to be a dot. Leaving it empty would
157 not add any suffix.
158
159 --no-binary::
160 Don't output contents of changes in binary files, just take note
161 that they differ. Note that this disable the patch to be properly
162 applied. By default the contents of changes in those files are
163 encoded in the patch.
164
165 CONFIGURATION
166 -------------
167 You can specify extra mail header lines to be added to each message
168 in the repository configuration, new defaults for the subject prefix
169 and file suffix, and number patches when outputting more than one.
170
171 ------------
172 [format]
173 headers = "Organization: git-foo\n"
174 subjectprefix = CHANGE
175 suffix = .txt
176 numbered = auto
177 cc = <email>
178 ------------
179
180
181 EXAMPLES
182 --------
183
184 * Extract commits between revisions R1 and R2, and apply them on top of
185 the current branch using `git-am` to cherry-pick them:
186 +
187 ------------
188 $ git format-patch -k --stdout R1..R2 | git-am -3 -k
189 ------------
190
191 * Extract all commits which are in the current branch but not in the
192 origin branch:
193 +
194 ------------
195 $ git format-patch origin
196 ------------
197 +
198 For each commit a separate file is created in the current directory.
199
200 * Extract all commits that lead to 'origin' since the inception of the
201 project:
202 +
203 ------------
204 $ git format-patch \--root origin
205 ------------
206
207 * The same as the previous one:
208 +
209 ------------
210 $ git format-patch -M -B origin
211 ------------
212 +
213 Additionally, it detects and handles renames and complete rewrites
214 intelligently to produce a renaming patch. A renaming patch reduces
215 the amount of text output, and generally makes it easier to review it.
216 Note that the "patch" program does not understand renaming patches, so
217 use it only when you know the recipient uses git to apply your patch.
218
219 * Extract three topmost commits from the current branch and format them
220 as e-mailable patches:
221 +
222 ------------
223 $ git format-patch -3
224 ------------
225
226 SEE ALSO
227 --------
228 linkgit:git-am[1], linkgit:git-send-email[1]
229
230
231 Author
232 ------
233 Written by Junio C Hamano <junkio@cox.net>
234
235 Documentation
236 --------------
237 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
238
239 GIT
240 ---
241 Part of the linkgit:git[7] suite