blob: 6f6c34b0f4bc9ba18ec890dff1a6fe10af2fd68f [file] [log] [blame]
Petr Baudis42e2cba2005-10-21 02:28:42 +02001git-am(1)
Junio C Hamano05625af2005-10-21 20:57:34 -07002=========
Petr Baudis42e2cba2005-10-21 02:28:42 +02003
4NAME
5----
Junio C Hamanoc3f0baa2007-01-18 15:53:37 -08006git-am - Apply a series of patches from a mailbox
Petr Baudis42e2cba2005-10-21 02:28:42 +02007
8
9SYNOPSIS
10--------
Jonas Fonseca353ce812005-12-31 18:37:15 +010011[verse]
Felipe Contreras0460ed22013-05-08 20:16:55 -050012'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
Remi Lespinete97a5e72015-08-04 22:19:26 +080013 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
Giuseppe Bilotta86c91f92009-08-04 13:16:49 +020014 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
Junio C Hamanob47dfe92009-01-11 22:21:48 -080015 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
Johannes Berg58725ef2012-03-28 13:11:28 +020016 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
Junio C Hamano2dfefe02014-03-25 11:01:31 -070017 [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
Štěpán Němec0adda932010-10-08 19:31:17 +020018 [(<mbox> | <Maildir>)...]
Junio C Hamano9ca488c2018-03-06 14:54:02 -080019'git am' (--continue | --skip | --abort | --quit | --show-current-patch)
Petr Baudis42e2cba2005-10-21 02:28:42 +020020
21DESCRIPTION
22-----------
23Splits mail messages in a mailbox into commit log message,
24authorship information and patches, and applies them to the
25current branch.
26
Junio C Hamanobaa720f2005-10-20 22:14:14 -070027OPTIONS
28-------
Štěpán Němec0adda932010-10-08 19:31:17 +020029(<mbox>|<Maildir>)...::
Michael S. Tsirkind4144612007-02-09 12:23:23 +020030 The list of mailbox files to read patches from. If you do not
David J. Mellor07f57462009-03-01 22:37:41 -080031 supply this argument, the command reads from the standard input.
32 If you supply directories, they will be treated as Maildirs.
Michael S. Tsirkind4144612007-02-09 12:23:23 +020033
Stephan Beyer32402402008-06-08 03:36:09 +020034-s::
35--signoff::
Stephen Boyd3db964b2009-05-04 22:18:42 -070036 Add a `Signed-off-by:` line to the commit message, using
Junio C Hamanobaa720f2005-10-20 22:14:14 -070037 the committer identity of yourself.
David A. Wheelerb2c150d2016-01-05 14:20:26 -050038 See the signoff option in linkgit:git-commit[1] for more information.
Junio C Hamanobaa720f2005-10-20 22:14:14 -070039
Stephan Beyer32402402008-06-08 03:36:09 +020040-k::
41--keep::
Thomas Rast0b444cd2010-01-10 00:33:00 +010042 Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamanod84029b2007-01-08 13:59:15 -080043
Thomas Rastf7e5ea12012-01-16 11:53:00 +010044--keep-non-patch::
45 Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
46
Felipe Contreras0460ed22013-05-08 20:16:55 -050047--[no-]keep-cr::
Stefan-W. Hahnad2c9282010-02-27 15:20:26 +010048 With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
49 with the same option, to prevent it from stripping CR at the end of
Stefan-W. Hahne80d4cb2010-02-27 15:20:27 +010050 lines. `am.keepcr` configuration variable can be used to specify the
51 default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
Stefan-W. Hahnad2c9282010-02-27 15:20:26 +010052
Junio C Hamano017678b2009-08-26 21:36:05 -070053-c::
54--scissors::
55 Remove everything in body before a scissors line (see
Matthieu Moyafb5de72015-02-20 20:32:21 +010056 linkgit:git-mailinfo[1]). Can be activated by default using
57 the `mailinfo.scissors` configuration variable.
Junio C Hamano017678b2009-08-26 21:36:05 -070058
Michal Sojka8024d592010-03-04 13:08:28 +010059--no-scissors::
Nicolas Sebrecht434a6db2009-09-11 02:29:58 +020060 Ignore scissors lines (see linkgit:git-mailinfo[1]).
61
Paolo Bonzinia078f732014-11-25 15:00:56 +010062-m::
63--message-id::
64 Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]),
65 so that the Message-ID header is added to the commit message.
66 The `am.messageid` configuration variable can be used to specify
67 the default behaviour.
68
69--no-message-id::
70 Do not add the Message-ID header to the commit message.
71 `no-message-id` is useful to override `am.messageid`.
72
Stephen Boyd0e987a12009-06-16 15:33:01 -070073-q::
74--quiet::
75 Be quiet. Only print error messages.
76
Stephan Beyer32402402008-06-08 03:36:09 +020077-u::
78--utf8::
Thomas Rast0b444cd2010-01-10 00:33:00 +010079 Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
Junio C Hamanod84029b2007-01-08 13:59:15 -080080 The proposed commit log message taken from the e-mail
Frank Lichtenheld870e0d62007-05-14 16:44:53 +020081 is re-coded into UTF-8 encoding (configuration variable
Junio C Hamanod84029b2007-01-08 13:59:15 -080082 `i18n.commitencoding` can be used to specify project's
83 preferred encoding if it is not UTF-8).
84+
85This was optional in prior versions of git, but now it is the
David J. Mellor07f57462009-03-01 22:37:41 -080086default. You can use `--no-utf8` to override this.
Junio C Hamanod84029b2007-01-08 13:59:15 -080087
88--no-utf8::
Thomas Rast0b444cd2010-01-10 00:33:00 +010089 Pass `-n` flag to 'git mailinfo' (see
Dan McGee5162e692007-12-29 00:20:38 -060090 linkgit:git-mailinfo[1]).
Junio C Hamanobaa720f2005-10-20 22:14:14 -070091
Stephan Beyer32402402008-06-08 03:36:09 +020092-3::
93--3way::
Remi Lespinete97a5e72015-08-04 22:19:26 +080094--no-3way::
Junio C Hamanobaa720f2005-10-20 22:14:14 -070095 When the patch does not apply cleanly, fall back on
David J. Mellor07f57462009-03-01 22:37:41 -080096 3-way merge if the patch records the identity of blobs
97 it is supposed to apply to and we have those blobs
Remi Lespinete97a5e72015-08-04 22:19:26 +080098 available locally. `--no-3way` can be used to override
99 am.threeWay configuration variable. For more information,
100 see am.threeWay in linkgit:git-config[1].
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200101
Giuseppe Bilotta86c91f92009-08-04 13:16:49 +0200102--ignore-space-change::
103--ignore-whitespace::
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200104--whitespace=<option>::
Stephan Beyer32402402008-06-08 03:36:09 +0200105-C<n>::
106-p<n>::
Junio C Hamanob47dfe92009-01-11 22:21:48 -0800107--directory=<dir>::
maximilian attems2ae73452011-08-09 17:21:08 +0200108--exclude=<path>::
Johannes Berg58725ef2012-03-28 13:11:28 +0200109--include=<path>::
martin f. krafftb80da422009-01-23 11:31:21 +1100110--reject::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100111 These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200112 program that applies
113 the patch.
114
Chris Packham64981372014-03-11 16:51:57 +1300115--patch-format::
116 By default the command will try to detect the patch format
117 automatically. This option allows the user to bypass the automatic
118 detection and specify the patch format that the patch(es) should be
Eric Wongd9925d12016-06-05 04:46:41 +0000119 interpreted as. Valid formats are mbox, mboxrd,
120 stgit, stgit-series and hg.
Chris Packham64981372014-03-11 16:51:57 +1300121
Stephan Beyer32402402008-06-08 03:36:09 +0200122-i::
123--interactive::
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200124 Run interactively.
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700125
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900126--committer-date-is-author-date::
127 By default the command records the date from the e-mail
128 message as the commit author date, and uses the time of
129 commit creation as the committer date. This allows the
130 user to lie about the committer date by using the same
Stephen Boyde77063f2009-05-04 22:19:00 -0700131 value as the author date.
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900132
133--ignore-date::
134 By default the command records the date from the e-mail
135 message as the commit author date, and uses the time of
136 commit creation as the committer date. This allows the
Stephen Boyde77063f2009-05-04 22:19:00 -0700137 user to lie about the author date by using the same
138 value as the committer date.
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900139
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700140--skip::
141 Skip the current patch. This is only meaningful when
142 restarting an aborted patch.
143
Nicolas Vigier3b4e395f2014-02-01 02:18:01 +0000144-S[<keyid>]::
145--gpg-sign[=<keyid>]::
Matthieu Moy2b594bf2015-09-19 09:47:50 +0200146 GPG-sign commits. The `keyid` argument is optional and
147 defaults to the committer identity; if specified, it must be
148 stuck to the option without a space.
Nicolas Vigier3b4e395f2014-02-01 02:18:01 +0000149
Jeff Kingc8089af2010-02-11 17:27:14 -0500150--continue::
Stephan Beyer32402402008-06-08 03:36:09 +0200151-r::
152--resolved::
Junio C Hamano087b6742005-11-16 16:46:24 -0800153 After a patch failure (e.g. attempting to apply
154 conflicting patch), the user has applied it by hand and
155 the index file stores the result of the application.
156 Make a commit using the authorship and commit log
157 extracted from the e-mail message and the current index
158 file, and continue.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200159
Andrew Ruder5c19f242007-04-16 02:21:31 -0500160--resolvemsg=<msg>::
161 When a patch failure occurs, <msg> will be printed
162 to the screen before exiting. This overrides the
Kevin Bracey8ceb6fb2013-06-26 23:06:41 +0300163 standard message informing you to use `--continue`
Andrew Ruder5c19f242007-04-16 02:21:31 -0500164 or `--skip` to handle the failure. This is solely
Thomas Rast0b444cd2010-01-10 00:33:00 +0100165 for internal use between 'git rebase' and 'git am'.
Andrew Ruder5c19f242007-04-16 02:21:31 -0500166
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +0900167--abort::
168 Restore the original branch and abort the patching operation.
169
Nguyễn Thái Ngọc Duy65ed8ff2018-02-14 18:16:06 +0700170--quit::
171 Abort the patching operation but keep HEAD and the index
172 untouched.
173
Nguyễn Thái Ngọc Duy984913a2018-02-11 16:43:26 +0700174--show-current-patch::
175 Show the patch being applied when "git am" is stopped because
176 of conflicts.
177
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700178DISCUSSION
179----------
180
Junio C Hamano24998572007-03-24 03:08:54 -0700181The commit author name is taken from the "From: " line of the
Stephen Boyde77063f2009-05-04 22:19:00 -0700182message, and commit author date is taken from the "Date: " line
Junio C Hamano24998572007-03-24 03:08:54 -0700183of the message. The "Subject: " line is used as the title of
184the commit, after stripping common prefix "[PATCH <anything>]".
Stephen Boyd3db964b2009-05-04 22:18:42 -0700185The "Subject: " line is supposed to concisely describe what the
186commit is about in one line of text.
Junio C Hamano24998572007-03-24 03:08:54 -0700187
Nanako Shiraishif43c97f2009-08-25 17:20:00 +0900188"From: " and "Subject: " lines starting the body override the respective
189commit author name and title values taken from the headers.
Junio C Hamano24998572007-03-24 03:08:54 -0700190
191The commit message is formed by the title taken from the
192"Subject: ", a blank line and the body of the message up to
Stephen Boyd3db964b2009-05-04 22:18:42 -0700193where the patch begins. Excess whitespace at the end of each
194line is automatically stripped.
Junio C Hamano24998572007-03-24 03:08:54 -0700195
196The patch is expected to be inline, directly following the
David J. Mellor07f57462009-03-01 22:37:41 -0800197message. Any line that is of the form:
Junio C Hamano24998572007-03-24 03:08:54 -0700198
199* three-dashes and end-of-line, or
200* a line that begins with "diff -", or
201* a line that begins with "Index: "
202
203is taken as the beginning of a patch, and the commit log message
204is terminated before the first occurrence of such a line.
205
Stephen Boyd3db964b2009-05-04 22:18:42 -0700206When initially invoking `git am`, you give it the names of the mailboxes
David J. Mellor07f57462009-03-01 22:37:41 -0800207to process. Upon seeing the first patch that does not apply, it
208aborts in the middle. You can recover from this in one of two ways:
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700209
Matthieu Moybcf96262016-06-28 13:40:11 +0200210. skip the current patch by re-running the command with the `--skip`
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700211 option.
212
Junio C Hamano087b6742005-11-16 16:46:24 -0800213. hand resolve the conflict in the working directory, and update
David J. Mellor07f57462009-03-01 22:37:41 -0800214 the index file to bring it into a state that the patch should
Matthieu Moybcf96262016-06-28 13:40:11 +0200215 have produced. Then run the command with the `--continue` option.
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700216
SZEDER Gáborb5f306f2011-03-22 19:42:25 +0100217The command refuses to process new mailboxes until the current
218operation is finished, so if you decide to start over from scratch,
219run `git am --abort` before running the command with mailbox
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700220names.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200221
Brian Gernhardt98690992008-07-08 00:12:22 -0400222Before any patches are applied, ORIG_HEAD is set to the tip of the
223current branch. This is useful if you have problems with multiple
224commits, like running 'git am' on the wrong branch or an error in the
225commits that is more easily fixed by changing the mailbox (e.g.
226errors in the "From:" lines).
227
Jonathan Nieder0e3d40c2014-02-24 12:38:29 -0800228HOOKS
229-----
230This command can run `applypatch-msg`, `pre-applypatch`,
231and `post-applypatch` hooks. See linkgit:githooks[5] for more
232information.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200233
234SEE ALSO
235--------
Dan McGee5162e692007-12-29 00:20:38 -0600236linkgit:git-apply[1].
Petr Baudis42e2cba2005-10-21 02:28:42 +0200237
Petr Baudis42e2cba2005-10-21 02:28:42 +0200238GIT
239---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200240Part of the linkgit:git[1] suite