blob: 320da6c4f7624bceed05011033e177b234e28564 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-am(1)
2=========
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-am - Apply a series of patches from a mailbox
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
Junio C Hamano3d1b5a12013-05-17 23:34:0212'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
Junio C Hamano9c512872015-08-12 21:59:2513 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
Junio C Hamanofe24db02009-08-22 05:10:4714 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
Junio C Hamanocc0cb312009-01-22 03:38:5015 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
Junio C Hamano0c1b64e2012-04-20 23:50:4916 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
Junio C Hamano3214e5f2014-03-25 19:54:3817 [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
Junio C Hamano608b11d2021-05-16 21:40:4518 [--quoted-cr=<action>]
Junio C Hamanoe872a1c2022-01-05 22:15:1319 [--empty=(stop|drop|keep)]
Junio C Hamanod2179ef2010-10-22 04:12:1720 [(<mbox> | <Maildir>)...]
Junio C Hamanoe872a1c2022-01-05 22:15:1321'git am' (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)] | --allow-empty)
Junio C Hamano1a4e8412005-12-27 08:17:2322
23DESCRIPTION
24-----------
25Splits mail messages in a mailbox into commit log message,
26authorship information and patches, and applies them to the
27current branch.
28
29OPTIONS
30-------
Junio C Hamanod2179ef2010-10-22 04:12:1731(<mbox>|<Maildir>)...::
Junio C Hamano9cb74f22007-02-12 04:15:0532The list of mailbox files to read patches from. If you do not
Junio C Hamano7924d5e2009-03-03 08:28:4833supply this argument, the command reads from the standard input.
34If you supply directories, they will be treated as Maildirs.
Junio C Hamano9cb74f22007-02-12 04:15:0535
Junio C Hamanoeb415992008-06-08 22:49:4736-s::
37--signoff::
Junio C Hamanodf3d3cd2020-11-02 22:05:0538Add a `Signed-off-by` trailer to the commit message, using
Junio C Hamano1a4e8412005-12-27 08:17:2339the committer identity of yourself.
Junio C Hamano4e6ba272016-01-20 23:23:1940See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2341
Junio C Hamanoeb415992008-06-08 22:49:4742-k::
43--keep::
Junio C Hamano1aa40d22010-01-21 17:46:4344Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4745
Junio C Hamanob5be0522012-01-29 22:20:1946--keep-non-patch::
47Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
48
Junio C Hamano3d1b5a12013-05-17 23:34:0249--[no-]keep-cr::
Junio C Hamanocaa712a2010-03-11 01:17:3550With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
51with the same option, to prevent it from stripping CR at the end of
52lines. `am.keepcr` configuration variable can be used to specify the
53default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
54
Junio C Hamanoc28068f2009-09-08 00:55:2355-c::
56--scissors::
57Remove everything in body before a scissors line (see
Junio C Hamano7f1bc9d2015-03-05 22:38:2658linkgit:git-mailinfo[1]). Can be activated by default using
59the `mailinfo.scissors` configuration variable.
Junio C Hamanoc28068f2009-09-08 00:55:2360
Junio C Hamano01f1fbd2010-03-05 07:36:4161--no-scissors::
Junio C Hamanocf5b7732009-09-11 23:28:3262Ignore scissors lines (see linkgit:git-mailinfo[1]).
63
Junio C Hamano608b11d2021-05-16 21:40:4564--quoted-cr=<action>::
65This flag will be passed down to 'git mailinfo' (see linkgit:git-mailinfo[1]).
66
Junio C Hamanoe872a1c2022-01-05 22:15:1367--empty=(stop|drop|keep)::
68By default, or when the option is set to 'stop', the command
69errors out on an input e-mail message lacking a patch
70and stops into the middle of the current am session. When this
71option is set to 'drop', skip such an e-mail message instead.
72When this option is set to 'keep', create an empty commit,
73recording the contents of the e-mail message as its log.
74
Junio C Hamano6df93d92014-12-22 22:48:0975-m::
76--message-id::
77Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
78so that the Message-ID header is added to the commit message.
79The `am.messageid` configuration variable can be used to specify
80the default behaviour.
81
82--no-message-id::
83Do not add the Message-ID header to the commit message.
84`no-message-id` is useful to override `am.messageid`.
85
Junio C Hamano2c14c8d2009-07-02 03:17:0086-q::
87--quiet::
88Be quiet. Only print error messages.
89
Junio C Hamanoeb415992008-06-08 22:49:4790-u::
91--utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4392Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4793The proposed commit log message taken from the e-mail
Junio C Hamano0430e3a2007-05-15 03:13:1794is re-coded into UTF-8 encoding (configuration variable
Junio C Hamanoa372d5b2021-02-26 01:34:3795`i18n.commitEncoding` can be used to specify project's
Junio C Hamano1d3a6c72007-01-09 11:13:4796preferred encoding if it is not UTF-8).
97+
98This was optional in prior versions of git, but now it is the
Junio C Hamano7924d5e2009-03-03 08:28:4899default. You can use `--no-utf8` to override this.
Junio C Hamano1d3a6c72007-01-09 11:13:47100
101--no-utf8::
Junio C Hamano1aa40d22010-01-21 17:46:43102Pass `-n` flag to 'git mailinfo' (see
Junio C Hamano35738e82008-01-07 07:55:46103linkgit:git-mailinfo[1]).
Junio C Hamano1a4e8412005-12-27 08:17:23104
Junio C Hamanoeb415992008-06-08 22:49:47105-3::
106--3way::
Junio C Hamano9c512872015-08-12 21:59:25107--no-3way::
Junio C Hamano1a4e8412005-12-27 08:17:23108When the patch does not apply cleanly, fall back on
Junio C Hamano7924d5e2009-03-03 08:28:481093-way merge if the patch records the identity of blobs
110it is supposed to apply to and we have those blobs
Junio C Hamano9c512872015-08-12 21:59:25111available locally. `--no-3way` can be used to override
112am.threeWay configuration variable. For more information,
113see am.threeWay in linkgit:git-config[1].
Junio C Hamano0430e3a2007-05-15 03:13:17114
Junio C Hamano04495a12022-08-18 21:13:08115include::rerere-options.txt[]
Junio C Hamano6b7d2152019-04-16 12:51:15116
Junio C Hamanofe24db02009-08-22 05:10:47117--ignore-space-change::
118--ignore-whitespace::
Junio C Hamano0430e3a2007-05-15 03:13:17119--whitespace=<option>::
Junio C Hamanoeb415992008-06-08 22:49:47120-C<n>::
121-p<n>::
Junio C Hamanocc0cb312009-01-22 03:38:50122--directory=<dir>::
Junio C Hamanodac21e72011-08-19 06:50:43123--exclude=<path>::
Junio C Hamano0c1b64e2012-04-20 23:50:49124--include=<path>::
Junio C Hamano22bcc112009-01-24 08:05:18125--reject::
Junio C Hamano1aa40d22010-01-21 17:46:43126These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Junio C Hamano0430e3a2007-05-15 03:13:17127program that applies
128the patch.
129
Junio C Hamano3214e5f2014-03-25 19:54:38130--patch-format::
131By default the command will try to detect the patch format
132automatically. This option allows the user to bypass the automatic
133detection and specify the patch format that the patch(es) should be
Junio C Hamanoc6c919b2016-07-06 21:34:15134interpreted as. Valid formats are mbox, mboxrd,
135stgit, stgit-series and hg.
Junio C Hamano3214e5f2014-03-25 19:54:38136
Junio C Hamanoeb415992008-06-08 22:49:47137-i::
138--interactive::
Junio C Hamano0430e3a2007-05-15 03:13:17139Run interactively.
Junio C Hamano1a4e8412005-12-27 08:17:23140
Junio C Hamanoa3bb6eb2009-02-05 01:26:33141--committer-date-is-author-date::
142By default the command records the date from the e-mail
143message as the commit author date, and uses the time of
144commit creation as the committer date. This allows the
145user to lie about the committer date by using the same
Junio C Hamano86f31572009-05-06 07:38:42146value as the author date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33147
148--ignore-date::
149By default the command records the date from the e-mail
150message as the commit author date, and uses the time of
151commit creation as the committer date. This allows the
Junio C Hamano86f31572009-05-06 07:38:42152user to lie about the author date by using the same
153value as the committer date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33154
Junio C Hamano1a4e8412005-12-27 08:17:23155--skip::
156Skip the current patch. This is only meaningful when
157restarting an aborted patch.
158
Junio C Hamano5b3533d2014-02-27 23:07:15159-S[<keyid>]::
160--gpg-sign[=<keyid>]::
Junio C Hamano67bf2242020-04-22 21:41:44161--no-gpg-sign::
Junio C Hamano1eb56092015-10-05 20:39:53162GPG-sign commits. The `keyid` argument is optional and
163defaults to the committer identity; if specified, it must be
Junio C Hamano67bf2242020-04-22 21:41:44164stuck to the option without a space. `--no-gpg-sign` is useful to
165countermand both `commit.gpgSign` configuration variable, and
166earlier `--gpg-sign`.
Junio C Hamano5b3533d2014-02-27 23:07:15167
Junio C Hamanob2628b12010-02-12 08:08:08168--continue::
Junio C Hamanoeb415992008-06-08 22:49:47169-r::
170--resolved::
Junio C Hamano1a4e8412005-12-27 08:17:23171After a patch failure (e.g. attempting to apply
172conflicting patch), the user has applied it by hand and
173the index file stores the result of the application.
174Make a commit using the authorship and commit log
175extracted from the e-mail message and the current index
176file, and continue.
177
Junio C Hamano0e3cb532007-04-17 08:28:11178--resolvemsg=<msg>::
179When a patch failure occurs, <msg> will be printed
180to the screen before exiting. This overrides the
Junio C Hamanoa1952302013-07-01 21:31:18181standard message informing you to use `--continue`
Junio C Hamano0e3cb532007-04-17 08:28:11182or `--skip` to handle the failure. This is solely
Junio C Hamano1aa40d22010-01-21 17:46:43183for internal use between 'git rebase' and 'git am'.
Junio C Hamano0e3cb532007-04-17 08:28:11184
Junio C Hamano5ba2c222008-07-21 04:33:46185--abort::
186Restore the original branch and abort the patching operation.
Junio C Hamanoeb4d5672021-09-23 21:35:54187Revert contents of files involved in the am operation to their
188pre-am state.
Junio C Hamano5ba2c222008-07-21 04:33:46189
Junio C Hamano615c3b32018-02-28 23:40:27190--quit::
191Abort the patching operation but keep HEAD and the index
192untouched.
193
Junio C Hamano35a51552020-03-10 06:08:58194--show-current-patch[=(diff|raw)]::
195Show the message at which `git am` has stopped due to
196conflicts. If `raw` is specified, show the raw contents of
197the e-mail message; if `diff`, show the diff portion only.
198Defaults to `raw`.
Junio C Hamano664750f2018-03-06 23:25:44199
Junio C Hamanoe872a1c2022-01-05 22:15:13200--allow-empty::
201After a patch failure on an input e-mail message lacking a patch,
202create an empty commit with the contents of the e-mail message
203as its log message.
204
Junio C Hamano1a4e8412005-12-27 08:17:23205DISCUSSION
206----------
207
Junio C Hamano35e57552007-03-25 07:54:35208The commit author name is taken from the "From: " line of the
Junio C Hamano86f31572009-05-06 07:38:42209message, and commit author date is taken from the "Date: " line
Junio C Hamano35e57552007-03-25 07:54:35210of the message. The "Subject: " line is used as the title of
211the commit, after stripping common prefix "[PATCH <anything>]".
Junio C Hamano86f31572009-05-06 07:38:42212The "Subject: " line is supposed to concisely describe what the
213commit is about in one line of text.
Junio C Hamano35e57552007-03-25 07:54:35214
Junio C Hamano9d828c92020-01-08 21:18:22215"From: ", "Date: ", and "Subject: " lines starting the body override the
216respective commit author name and title values taken from the headers.
Junio C Hamano35e57552007-03-25 07:54:35217
218The commit message is formed by the title taken from the
219"Subject: ", a blank line and the body of the message up to
Junio C Hamano86f31572009-05-06 07:38:42220where the patch begins. Excess whitespace at the end of each
221line is automatically stripped.
Junio C Hamano35e57552007-03-25 07:54:35222
223The patch is expected to be inline, directly following the
Junio C Hamano7924d5e2009-03-03 08:28:48224message. Any line that is of the form:
Junio C Hamano35e57552007-03-25 07:54:35225
226* three-dashes and end-of-line, or
227* a line that begins with "diff -", or
228* a line that begins with "Index: "
229
230is taken as the beginning of a patch, and the commit log message
231is terminated before the first occurrence of such a line.
232
Junio C Hamano86f31572009-05-06 07:38:42233When initially invoking `git am`, you give it the names of the mailboxes
Junio C Hamano7924d5e2009-03-03 08:28:48234to process. Upon seeing the first patch that does not apply, it
235aborts in the middle. You can recover from this in one of two ways:
Junio C Hamano1a4e8412005-12-27 08:17:23236
Junio C Hamano92d80372016-07-13 22:00:05237. skip the current patch by re-running the command with the `--skip`
Junio C Hamano1a4e8412005-12-27 08:17:23238 option.
239
240. hand resolve the conflict in the working directory, and update
Junio C Hamano7924d5e2009-03-03 08:28:48241 the index file to bring it into a state that the patch should
Junio C Hamano92d80372016-07-13 22:00:05242 have produced. Then run the command with the `--continue` option.
Junio C Hamano1a4e8412005-12-27 08:17:23243
Junio C Hamano78f25df2011-03-23 00:05:35244The command refuses to process new mailboxes until the current
245operation is finished, so if you decide to start over from scratch,
246run `git am --abort` before running the command with mailbox
Junio C Hamano1a4e8412005-12-27 08:17:23247names.
248
Junio C Hamano38ddcce2008-07-15 15:49:03249Before any patches are applied, ORIG_HEAD is set to the tip of the
250current branch. This is useful if you have problems with multiple
251commits, like running 'git am' on the wrong branch or an error in the
252commits that is more easily fixed by changing the mailbox (e.g.
253errors in the "From:" lines).
254
Junio C Hamano81703b22014-03-14 22:00:27255HOOKS
256-----
257This command can run `applypatch-msg`, `pre-applypatch`,
258and `post-applypatch` hooks. See linkgit:githooks[5] for more
259information.
Junio C Hamano1a4e8412005-12-27 08:17:23260
261SEE ALSO
262--------
Junio C Hamano35738e82008-01-07 07:55:46263linkgit:git-apply[1].
Junio C Hamano1a4e8412005-12-27 08:17:23264
Junio C Hamano1a4e8412005-12-27 08:17:23265GIT
266---
Junio C Hamanof7c042d2008-06-06 22:50:53267Part of the linkgit:git[1] suite