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