blob: 900be198b14e933d19f87febd9860cb0c67a6bf0 [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 Hamanod2309372023-01-16 21:19:0412'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--no-verify]
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
Junio C Hamano0bfdf2e2023-03-30 22:52:5927current branch. You could think of it as a reverse operation
28of linkgit:git-format-patch[1] run on a branch with a straight
29history without merges.
Junio C Hamano1a4e8412005-12-27 08:17:2330
31OPTIONS
32-------
Junio C Hamanod2179ef2010-10-22 04:12:1733(<mbox>|<Maildir>)...::
Junio C Hamano9cb74f22007-02-12 04:15:0534The list of mailbox files to read patches from. If you do not
Junio C Hamano7924d5e2009-03-03 08:28:4835supply this argument, the command reads from the standard input.
36If you supply directories, they will be treated as Maildirs.
Junio C Hamano9cb74f22007-02-12 04:15:0537
Junio C Hamanoeb415992008-06-08 22:49:4738-s::
39--signoff::
Junio C Hamanodf3d3cd2020-11-02 22:05:0540Add a `Signed-off-by` trailer to the commit message, using
Junio C Hamano1a4e8412005-12-27 08:17:2341the committer identity of yourself.
Junio C Hamano4e6ba272016-01-20 23:23:1942See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2343
Junio C Hamanoeb415992008-06-08 22:49:4744-k::
45--keep::
Junio C Hamano1aa40d22010-01-21 17:46:4346Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4747
Junio C Hamanob5be0522012-01-29 22:20:1948--keep-non-patch::
49Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
50
Junio C Hamano3d1b5a12013-05-17 23:34:0251--[no-]keep-cr::
Junio C Hamanocaa712a2010-03-11 01:17:3552With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
53with the same option, to prevent it from stripping CR at the end of
54lines. `am.keepcr` configuration variable can be used to specify the
55default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
56
Junio C Hamanoc28068f2009-09-08 00:55:2357-c::
58--scissors::
59Remove everything in body before a scissors line (see
Junio C Hamano7f1bc9d2015-03-05 22:38:2660linkgit:git-mailinfo[1]). Can be activated by default using
61the `mailinfo.scissors` configuration variable.
Junio C Hamanoc28068f2009-09-08 00:55:2362
Junio C Hamano01f1fbd2010-03-05 07:36:4163--no-scissors::
Junio C Hamanocf5b7732009-09-11 23:28:3264Ignore scissors lines (see linkgit:git-mailinfo[1]).
65
Junio C Hamano608b11d2021-05-16 21:40:4566--quoted-cr=<action>::
67This flag will be passed down to 'git mailinfo' (see linkgit:git-mailinfo[1]).
68
Junio C Hamanoe872a1c2022-01-05 22:15:1369--empty=(stop|drop|keep)::
70By default, or when the option is set to 'stop', the command
71errors out on an input e-mail message lacking a patch
72and stops into the middle of the current am session. When this
73option is set to 'drop', skip such an e-mail message instead.
74When this option is set to 'keep', create an empty commit,
75recording the contents of the e-mail message as its log.
76
Junio C Hamano6df93d92014-12-22 22:48:0977-m::
78--message-id::
79Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
80so that the Message-ID header is added to the commit message.
81The `am.messageid` configuration variable can be used to specify
82the default behaviour.
83
84--no-message-id::
85Do not add the Message-ID header to the commit message.
86`no-message-id` is useful to override `am.messageid`.
87
Junio C Hamano2c14c8d2009-07-02 03:17:0088-q::
89--quiet::
90Be quiet. Only print error messages.
91
Junio C Hamanoeb415992008-06-08 22:49:4792-u::
93--utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4394Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4795The proposed commit log message taken from the e-mail
Junio C Hamano0430e3a2007-05-15 03:13:1796is re-coded into UTF-8 encoding (configuration variable
Junio C Hamanoa372d5b2021-02-26 01:34:3797`i18n.commitEncoding` can be used to specify project's
Junio C Hamano1d3a6c72007-01-09 11:13:4798preferred encoding if it is not UTF-8).
99+
100This was optional in prior versions of git, but now it is the
Junio C Hamano7924d5e2009-03-03 08:28:48101default. You can use `--no-utf8` to override this.
Junio C Hamano1d3a6c72007-01-09 11:13:47102
103--no-utf8::
Junio C Hamano1aa40d22010-01-21 17:46:43104Pass `-n` flag to 'git mailinfo' (see
Junio C Hamano35738e82008-01-07 07:55:46105linkgit:git-mailinfo[1]).
Junio C Hamano1a4e8412005-12-27 08:17:23106
Junio C Hamanoeb415992008-06-08 22:49:47107-3::
108--3way::
Junio C Hamano9c512872015-08-12 21:59:25109--no-3way::
Junio C Hamano1a4e8412005-12-27 08:17:23110When the patch does not apply cleanly, fall back on
Junio C Hamano7924d5e2009-03-03 08:28:481113-way merge if the patch records the identity of blobs
112it is supposed to apply to and we have those blobs
Junio C Hamano9c512872015-08-12 21:59:25113available locally. `--no-3way` can be used to override
114am.threeWay configuration variable. For more information,
115see am.threeWay in linkgit:git-config[1].
Junio C Hamano0430e3a2007-05-15 03:13:17116
Junio C Hamano04495a12022-08-18 21:13:08117include::rerere-options.txt[]
Junio C Hamano6b7d2152019-04-16 12:51:15118
Junio C Hamanofe24db02009-08-22 05:10:47119--ignore-space-change::
120--ignore-whitespace::
Junio C Hamano0430e3a2007-05-15 03:13:17121--whitespace=<option>::
Junio C Hamanoeb415992008-06-08 22:49:47122-C<n>::
123-p<n>::
Junio C Hamanocc0cb312009-01-22 03:38:50124--directory=<dir>::
Junio C Hamanodac21e72011-08-19 06:50:43125--exclude=<path>::
Junio C Hamano0c1b64e2012-04-20 23:50:49126--include=<path>::
Junio C Hamano22bcc112009-01-24 08:05:18127--reject::
Junio C Hamano1aa40d22010-01-21 17:46:43128These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Junio C Hamano0430e3a2007-05-15 03:13:17129program that applies
130the patch.
131
Junio C Hamano3214e5f2014-03-25 19:54:38132--patch-format::
133By default the command will try to detect the patch format
134automatically. This option allows the user to bypass the automatic
135detection and specify the patch format that the patch(es) should be
Junio C Hamanoc6c919b2016-07-06 21:34:15136interpreted as. Valid formats are mbox, mboxrd,
137stgit, stgit-series and hg.
Junio C Hamano3214e5f2014-03-25 19:54:38138
Junio C Hamanoeb415992008-06-08 22:49:47139-i::
140--interactive::
Junio C Hamano0430e3a2007-05-15 03:13:17141Run interactively.
Junio C Hamano1a4e8412005-12-27 08:17:23142
Junio C Hamanod2309372023-01-16 21:19:04143-n::
144--no-verify::
145By default, the pre-applypatch and applypatch-msg hooks are run.
146When any of `--no-verify` or `-n` is given, these are bypassed.
147See also linkgit:githooks[5].
148
Junio C Hamanoa3bb6eb2009-02-05 01:26:33149--committer-date-is-author-date::
150By default the command records the date from the e-mail
151message as the commit author date, and uses the time of
152commit creation as the committer date. This allows the
153user to lie about the committer date by using the same
Junio C Hamano86f31572009-05-06 07:38:42154value as the author date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33155
156--ignore-date::
157By default the command records the date from the e-mail
158message as the commit author date, and uses the time of
159commit creation as the committer date. This allows the
Junio C Hamano86f31572009-05-06 07:38:42160user to lie about the author date by using the same
161value as the committer date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33162
Junio C Hamano1a4e8412005-12-27 08:17:23163--skip::
164Skip the current patch. This is only meaningful when
165restarting an aborted patch.
166
Junio C Hamano5b3533d2014-02-27 23:07:15167-S[<keyid>]::
168--gpg-sign[=<keyid>]::
Junio C Hamano67bf2242020-04-22 21:41:44169--no-gpg-sign::
Junio C Hamano1eb56092015-10-05 20:39:53170GPG-sign commits. The `keyid` argument is optional and
171defaults to the committer identity; if specified, it must be
Junio C Hamano67bf2242020-04-22 21:41:44172stuck to the option without a space. `--no-gpg-sign` is useful to
173countermand both `commit.gpgSign` configuration variable, and
174earlier `--gpg-sign`.
Junio C Hamano5b3533d2014-02-27 23:07:15175
Junio C Hamanob2628b12010-02-12 08:08:08176--continue::
Junio C Hamanoeb415992008-06-08 22:49:47177-r::
178--resolved::
Junio C Hamano1a4e8412005-12-27 08:17:23179After a patch failure (e.g. attempting to apply
180conflicting patch), the user has applied it by hand and
181the index file stores the result of the application.
182Make a commit using the authorship and commit log
183extracted from the e-mail message and the current index
184file, and continue.
185
Junio C Hamano0e3cb532007-04-17 08:28:11186--resolvemsg=<msg>::
187When a patch failure occurs, <msg> will be printed
188to the screen before exiting. This overrides the
Junio C Hamanoa1952302013-07-01 21:31:18189standard message informing you to use `--continue`
Junio C Hamano0e3cb532007-04-17 08:28:11190or `--skip` to handle the failure. This is solely
Junio C Hamano1aa40d22010-01-21 17:46:43191for internal use between 'git rebase' and 'git am'.
Junio C Hamano0e3cb532007-04-17 08:28:11192
Junio C Hamano5ba2c222008-07-21 04:33:46193--abort::
194Restore the original branch and abort the patching operation.
Junio C Hamanoeb4d5672021-09-23 21:35:54195Revert contents of files involved in the am operation to their
196pre-am state.
Junio C Hamano5ba2c222008-07-21 04:33:46197
Junio C Hamano615c3b32018-02-28 23:40:27198--quit::
199Abort the patching operation but keep HEAD and the index
200untouched.
201
Junio C Hamano35a51552020-03-10 06:08:58202--show-current-patch[=(diff|raw)]::
203Show the message at which `git am` has stopped due to
204conflicts. If `raw` is specified, show the raw contents of
205the e-mail message; if `diff`, show the diff portion only.
206Defaults to `raw`.
Junio C Hamano664750f2018-03-06 23:25:44207
Junio C Hamanoe872a1c2022-01-05 22:15:13208--allow-empty::
209After a patch failure on an input e-mail message lacking a patch,
210create an empty commit with the contents of the e-mail message
211as its log message.
212
Junio C Hamano1a4e8412005-12-27 08:17:23213DISCUSSION
214----------
215
Junio C Hamano35e57552007-03-25 07:54:35216The commit author name is taken from the "From: " line of the
Junio C Hamano86f31572009-05-06 07:38:42217message, and commit author date is taken from the "Date: " line
Junio C Hamano35e57552007-03-25 07:54:35218of the message. The "Subject: " line is used as the title of
219the commit, after stripping common prefix "[PATCH <anything>]".
Junio C Hamano86f31572009-05-06 07:38:42220The "Subject: " line is supposed to concisely describe what the
221commit is about in one line of text.
Junio C Hamano35e57552007-03-25 07:54:35222
Junio C Hamano9d828c92020-01-08 21:18:22223"From: ", "Date: ", and "Subject: " lines starting the body override the
224respective commit author name and title values taken from the headers.
Junio C Hamano35e57552007-03-25 07:54:35225
226The commit message is formed by the title taken from the
227"Subject: ", a blank line and the body of the message up to
Junio C Hamano86f31572009-05-06 07:38:42228where the patch begins. Excess whitespace at the end of each
229line is automatically stripped.
Junio C Hamano35e57552007-03-25 07:54:35230
231The patch is expected to be inline, directly following the
Junio C Hamano7924d5e2009-03-03 08:28:48232message. Any line that is of the form:
Junio C Hamano35e57552007-03-25 07:54:35233
234* three-dashes and end-of-line, or
235* a line that begins with "diff -", or
236* a line that begins with "Index: "
237
238is taken as the beginning of a patch, and the commit log message
239is terminated before the first occurrence of such a line.
240
Junio C Hamano86f31572009-05-06 07:38:42241When initially invoking `git am`, you give it the names of the mailboxes
Junio C Hamano7924d5e2009-03-03 08:28:48242to process. Upon seeing the first patch that does not apply, it
243aborts in the middle. You can recover from this in one of two ways:
Junio C Hamano1a4e8412005-12-27 08:17:23244
Junio C Hamano92d80372016-07-13 22:00:05245. skip the current patch by re-running the command with the `--skip`
Junio C Hamano1a4e8412005-12-27 08:17:23246 option.
247
248. hand resolve the conflict in the working directory, and update
Junio C Hamano7924d5e2009-03-03 08:28:48249 the index file to bring it into a state that the patch should
Junio C Hamano92d80372016-07-13 22:00:05250 have produced. Then run the command with the `--continue` option.
Junio C Hamano1a4e8412005-12-27 08:17:23251
Junio C Hamano78f25df2011-03-23 00:05:35252The command refuses to process new mailboxes until the current
253operation is finished, so if you decide to start over from scratch,
254run `git am --abort` before running the command with mailbox
Junio C Hamano1a4e8412005-12-27 08:17:23255names.
256
Junio C Hamano38ddcce2008-07-15 15:49:03257Before any patches are applied, ORIG_HEAD is set to the tip of the
258current branch. This is useful if you have problems with multiple
259commits, like running 'git am' on the wrong branch or an error in the
260commits that is more easily fixed by changing the mailbox (e.g.
261errors in the "From:" lines).
262
Junio C Hamano81703b22014-03-14 22:00:27263HOOKS
264-----
265This command can run `applypatch-msg`, `pre-applypatch`,
266and `post-applypatch` hooks. See linkgit:githooks[5] for more
267information.
Junio C Hamano1a4e8412005-12-27 08:17:23268
Junio C Hamanoba8baee2022-09-14 20:25:23269CONFIGURATION
270-------------
271
272include::includes/cmd-config-section-all.txt[]
273
274include::config/am.txt[]
275
Junio C Hamano1a4e8412005-12-27 08:17:23276SEE ALSO
277--------
Junio C Hamano0bfdf2e2023-03-30 22:52:59278linkgit:git-apply[1],
279linkgit:git-format-patch[1].
Junio C Hamano1a4e8412005-12-27 08:17:23280
Junio C Hamano1a4e8412005-12-27 08:17:23281GIT
282---
Junio C Hamanof7c042d2008-06-06 22:50:53283Part of the linkgit:git[1] suite