blob: 12879e4029a7710e2d78bae476f7ad7d9b0fe830 [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 Hamanod2179ef2010-10-22 04:12:1718 [(<mbox> | <Maildir>)...]
Junio C Hamanob2628b12010-02-12 08:08:0819'git am' (--continue | --skip | --abort)
Junio C Hamano1a4e8412005-12-27 08:17:2320
21DESCRIPTION
22-----------
23Splits mail messages in a mailbox into commit log message,
24authorship information and patches, and applies them to the
25current branch.
26
27OPTIONS
28-------
Junio C Hamanod2179ef2010-10-22 04:12:1729(<mbox>|<Maildir>)...::
Junio C Hamano9cb74f22007-02-12 04:15:0530The list of mailbox files to read patches from. If you do not
Junio C Hamano7924d5e2009-03-03 08:28:4831supply this argument, the command reads from the standard input.
32If you supply directories, they will be treated as Maildirs.
Junio C Hamano9cb74f22007-02-12 04:15:0533
Junio C Hamanoeb415992008-06-08 22:49:4734-s::
35--signoff::
Junio C Hamano86f31572009-05-06 07:38:4236Add a `Signed-off-by:` line to the commit message, using
Junio C Hamano1a4e8412005-12-27 08:17:2337the committer identity of yourself.
Junio C Hamano4e6ba272016-01-20 23:23:1938See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2339
Junio C Hamanoeb415992008-06-08 22:49:4740-k::
41--keep::
Junio C Hamano1aa40d22010-01-21 17:46:4342Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4743
Junio C Hamanob5be0522012-01-29 22:20:1944--keep-non-patch::
45Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
46
Junio C Hamano3d1b5a12013-05-17 23:34:0247--[no-]keep-cr::
Junio C Hamanocaa712a2010-03-11 01:17:3548With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
49with the same option, to prevent it from stripping CR at the end of
50lines. `am.keepcr` configuration variable can be used to specify the
51default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
52
Junio C Hamanoc28068f2009-09-08 00:55:2353-c::
54--scissors::
55Remove everything in body before a scissors line (see
Junio C Hamano7f1bc9d2015-03-05 22:38:2656linkgit:git-mailinfo[1]). Can be activated by default using
57the `mailinfo.scissors` configuration variable.
Junio C Hamanoc28068f2009-09-08 00:55:2358
Junio C Hamano01f1fbd2010-03-05 07:36:4159--no-scissors::
Junio C Hamanocf5b7732009-09-11 23:28:3260Ignore scissors lines (see linkgit:git-mailinfo[1]).
61
Junio C Hamano6df93d92014-12-22 22:48:0962-m::
63--message-id::
64Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
65so that the Message-ID header is added to the commit message.
66The `am.messageid` configuration variable can be used to specify
67the default behaviour.
68
69--no-message-id::
70Do not add the Message-ID header to the commit message.
71`no-message-id` is useful to override `am.messageid`.
72
Junio C Hamano2c14c8d2009-07-02 03:17:0073-q::
74--quiet::
75Be quiet. Only print error messages.
76
Junio C Hamanoeb415992008-06-08 22:49:4777-u::
78--utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4379Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:4780The proposed commit log message taken from the e-mail
Junio C Hamano0430e3a2007-05-15 03:13:1781is re-coded into UTF-8 encoding (configuration variable
Junio C Hamano1d3a6c72007-01-09 11:13:4782`i18n.commitencoding` can be used to specify project's
83preferred encoding if it is not UTF-8).
84+
85This was optional in prior versions of git, but now it is the
Junio C Hamano7924d5e2009-03-03 08:28:4886default. You can use `--no-utf8` to override this.
Junio C Hamano1d3a6c72007-01-09 11:13:4787
88--no-utf8::
Junio C Hamano1aa40d22010-01-21 17:46:4389Pass `-n` flag to 'git mailinfo' (see
Junio C Hamano35738e82008-01-07 07:55:4690linkgit:git-mailinfo[1]).
Junio C Hamano1a4e8412005-12-27 08:17:2391
Junio C Hamanoeb415992008-06-08 22:49:4792-3::
93--3way::
Junio C Hamano9c512872015-08-12 21:59:2594--no-3way::
Junio C Hamano1a4e8412005-12-27 08:17:2395When the patch does not apply cleanly, fall back on
Junio C Hamano7924d5e2009-03-03 08:28:48963-way merge if the patch records the identity of blobs
97it is supposed to apply to and we have those blobs
Junio C Hamano9c512872015-08-12 21:59:2598available locally. `--no-3way` can be used to override
99am.threeWay configuration variable. For more information,
100see am.threeWay in linkgit:git-config[1].
Junio C Hamano0430e3a2007-05-15 03:13:17101
Junio C Hamanofe24db02009-08-22 05:10:47102--ignore-space-change::
103--ignore-whitespace::
Junio C Hamano0430e3a2007-05-15 03:13:17104--whitespace=<option>::
Junio C Hamanoeb415992008-06-08 22:49:47105-C<n>::
106-p<n>::
Junio C Hamanocc0cb312009-01-22 03:38:50107--directory=<dir>::
Junio C Hamanodac21e72011-08-19 06:50:43108--exclude=<path>::
Junio C Hamano0c1b64e2012-04-20 23:50:49109--include=<path>::
Junio C Hamano22bcc112009-01-24 08:05:18110--reject::
Junio C Hamano1aa40d22010-01-21 17:46:43111These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Junio C Hamano0430e3a2007-05-15 03:13:17112program that applies
113the patch.
114
Junio C Hamano3214e5f2014-03-25 19:54:38115--patch-format::
116By default the command will try to detect the patch format
117automatically. This option allows the user to bypass the automatic
118detection and specify the patch format that the patch(es) should be
Junio C Hamanoc6c919b2016-07-06 21:34:15119interpreted as. Valid formats are mbox, mboxrd,
120stgit, stgit-series and hg.
Junio C Hamano3214e5f2014-03-25 19:54:38121
Junio C Hamanoeb415992008-06-08 22:49:47122-i::
123--interactive::
Junio C Hamano0430e3a2007-05-15 03:13:17124Run interactively.
Junio C Hamano1a4e8412005-12-27 08:17:23125
Junio C Hamanoa3bb6eb2009-02-05 01:26:33126--committer-date-is-author-date::
127By default the command records the date from the e-mail
128message as the commit author date, and uses the time of
129commit creation as the committer date. This allows the
130user to lie about the committer date by using the same
Junio C Hamano86f31572009-05-06 07:38:42131value as the author date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33132
133--ignore-date::
134By default the command records the date from the e-mail
135message as the commit author date, and uses the time of
136commit creation as the committer date. This allows the
Junio C Hamano86f31572009-05-06 07:38:42137user to lie about the author date by using the same
138value as the committer date.
Junio C Hamanoa3bb6eb2009-02-05 01:26:33139
Junio C Hamano1a4e8412005-12-27 08:17:23140--skip::
141Skip the current patch. This is only meaningful when
142restarting an aborted patch.
143
Junio C Hamano5b3533d2014-02-27 23:07:15144-S[<keyid>]::
145--gpg-sign[=<keyid>]::
Junio C Hamano1eb56092015-10-05 20:39:53146GPG-sign commits. The `keyid` argument is optional and
147defaults to the committer identity; if specified, it must be
148stuck to the option without a space.
Junio C Hamano5b3533d2014-02-27 23:07:15149
Junio C Hamanob2628b12010-02-12 08:08:08150--continue::
Junio C Hamanoeb415992008-06-08 22:49:47151-r::
152--resolved::
Junio C Hamano1a4e8412005-12-27 08:17:23153After a patch failure (e.g. attempting to apply
154conflicting patch), the user has applied it by hand and
155the index file stores the result of the application.
156Make a commit using the authorship and commit log
157extracted from the e-mail message and the current index
158file, and continue.
159
Junio C Hamano0e3cb532007-04-17 08:28:11160--resolvemsg=<msg>::
161When a patch failure occurs, <msg> will be printed
162to the screen before exiting. This overrides the
Junio C Hamanoa1952302013-07-01 21:31:18163standard message informing you to use `--continue`
Junio C Hamano0e3cb532007-04-17 08:28:11164or `--skip` to handle the failure. This is solely
Junio C Hamano1aa40d22010-01-21 17:46:43165for internal use between 'git rebase' and 'git am'.
Junio C Hamano0e3cb532007-04-17 08:28:11166
Junio C Hamano5ba2c222008-07-21 04:33:46167--abort::
168Restore the original branch and abort the patching operation.
169
Junio C Hamano1a4e8412005-12-27 08:17:23170DISCUSSION
171----------
172
Junio C Hamano35e57552007-03-25 07:54:35173The commit author name is taken from the "From: " line of the
Junio C Hamano86f31572009-05-06 07:38:42174message, and commit author date is taken from the "Date: " line
Junio C Hamano35e57552007-03-25 07:54:35175of the message. The "Subject: " line is used as the title of
176the commit, after stripping common prefix "[PATCH <anything>]".
Junio C Hamano86f31572009-05-06 07:38:42177The "Subject: " line is supposed to concisely describe what the
178commit is about in one line of text.
Junio C Hamano35e57552007-03-25 07:54:35179
Junio C Hamanoc28068f2009-09-08 00:55:23180"From: " and "Subject: " lines starting the body override the respective
181commit author name and title values taken from the headers.
Junio C Hamano35e57552007-03-25 07:54:35182
183The commit message is formed by the title taken from the
184"Subject: ", a blank line and the body of the message up to
Junio C Hamano86f31572009-05-06 07:38:42185where the patch begins. Excess whitespace at the end of each
186line is automatically stripped.
Junio C Hamano35e57552007-03-25 07:54:35187
188The patch is expected to be inline, directly following the
Junio C Hamano7924d5e2009-03-03 08:28:48189message. Any line that is of the form:
Junio C Hamano35e57552007-03-25 07:54:35190
191* three-dashes and end-of-line, or
192* a line that begins with "diff -", or
193* a line that begins with "Index: "
194
195is taken as the beginning of a patch, and the commit log message
196is terminated before the first occurrence of such a line.
197
Junio C Hamano86f31572009-05-06 07:38:42198When initially invoking `git am`, you give it the names of the mailboxes
Junio C Hamano7924d5e2009-03-03 08:28:48199to process. Upon seeing the first patch that does not apply, it
200aborts in the middle. You can recover from this in one of two ways:
Junio C Hamano1a4e8412005-12-27 08:17:23201
Junio C Hamano92d80372016-07-13 22:00:05202. skip the current patch by re-running the command with the `--skip`
Junio C Hamano1a4e8412005-12-27 08:17:23203 option.
204
205. hand resolve the conflict in the working directory, and update
Junio C Hamano7924d5e2009-03-03 08:28:48206 the index file to bring it into a state that the patch should
Junio C Hamano92d80372016-07-13 22:00:05207 have produced. Then run the command with the `--continue` option.
Junio C Hamano1a4e8412005-12-27 08:17:23208
Junio C Hamano78f25df2011-03-23 00:05:35209The command refuses to process new mailboxes until the current
210operation is finished, so if you decide to start over from scratch,
211run `git am --abort` before running the command with mailbox
Junio C Hamano1a4e8412005-12-27 08:17:23212names.
213
Junio C Hamano38ddcce2008-07-15 15:49:03214Before any patches are applied, ORIG_HEAD is set to the tip of the
215current branch. This is useful if you have problems with multiple
216commits, like running 'git am' on the wrong branch or an error in the
217commits that is more easily fixed by changing the mailbox (e.g.
218errors in the "From:" lines).
219
Junio C Hamano81703b22014-03-14 22:00:27220HOOKS
221-----
222This command can run `applypatch-msg`, `pre-applypatch`,
223and `post-applypatch` hooks. See linkgit:githooks[5] for more
224information.
Junio C Hamano1a4e8412005-12-27 08:17:23225
226SEE ALSO
227--------
Junio C Hamano35738e82008-01-07 07:55:46228linkgit:git-apply[1].
Junio C Hamano1a4e8412005-12-27 08:17:23229
Junio C Hamano1a4e8412005-12-27 08:17:23230GIT
231---
Junio C Hamanof7c042d2008-06-06 22:50:53232Part of the linkgit:git[1] suite