blob: decd8ae12278cac8f3ea5e7dc9f1fb15b95629bd [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>)...]
Paolo Bonziniaa416b22020-02-20 15:15:19 +010019'git am' (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)])
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::
Bradley M. Kuhn3abd4a62020-10-19 18:03:55 -070036 Add a `Signed-off-by` trailer 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
Denton Liu77645b52021-02-24 12:26:39 -080082 `i18n.commitEncoding` can be used to specify project's
Junio C Hamanod84029b2007-01-08 13:59:15 -080083 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
Phillip Woodaba49542019-03-14 19:12:32 +0000102--rerere-autoupdate::
103--no-rerere-autoupdate::
104 Allow the rerere mechanism to update the index with the
105 result of auto-conflict resolution if possible.
106
Giuseppe Bilotta86c91f92009-08-04 13:16:49 +0200107--ignore-space-change::
108--ignore-whitespace::
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200109--whitespace=<option>::
Stephan Beyer32402402008-06-08 03:36:09 +0200110-C<n>::
111-p<n>::
Junio C Hamanob47dfe92009-01-11 22:21:48 -0800112--directory=<dir>::
maximilian attems2ae73452011-08-09 17:21:08 +0200113--exclude=<path>::
Johannes Berg58725ef2012-03-28 13:11:28 +0200114--include=<path>::
martin f. krafftb80da422009-01-23 11:31:21 +1100115--reject::
Thomas Rast0b444cd2010-01-10 00:33:00 +0100116 These flags are passed to the 'git apply' (see linkgit:git-apply[1])
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200117 program that applies
118 the patch.
119
Chris Packham64981372014-03-11 16:51:57 +1300120--patch-format::
121 By default the command will try to detect the patch format
122 automatically. This option allows the user to bypass the automatic
123 detection and specify the patch format that the patch(es) should be
Eric Wongd9925d12016-06-05 04:46:41 +0000124 interpreted as. Valid formats are mbox, mboxrd,
125 stgit, stgit-series and hg.
Chris Packham64981372014-03-11 16:51:57 +1300126
Stephan Beyer32402402008-06-08 03:36:09 +0200127-i::
128--interactive::
Frank Lichtenheld870e0d62007-05-14 16:44:53 +0200129 Run interactively.
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700130
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900131--committer-date-is-author-date::
132 By default the command records the date from the e-mail
133 message as the commit author date, and uses the time of
134 commit creation as the committer date. This allows the
135 user to lie about the committer date by using the same
Stephen Boyde77063f2009-05-04 22:19:00 -0700136 value as the author date.
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900137
138--ignore-date::
139 By default the command records the date from the e-mail
140 message as the commit author date, and uses the time of
141 commit creation as the committer date. This allows the
Stephen Boyde77063f2009-05-04 22:19:00 -0700142 user to lie about the author date by using the same
143 value as the committer date.
Nanako Shiraishia79ec622009-01-24 10:18:02 +0900144
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700145--skip::
146 Skip the current patch. This is only meaningful when
147 restarting an aborted patch.
148
Nicolas Vigier3b4e395f2014-02-01 02:18:01 +0000149-S[<keyid>]::
150--gpg-sign[=<keyid>]::
Đoàn Trần Công Danhae06ba62020-04-03 17:28:04 +0700151--no-gpg-sign::
Matthieu Moy2b594bf2015-09-19 09:47:50 +0200152 GPG-sign commits. The `keyid` argument is optional and
153 defaults to the committer identity; if specified, it must be
Đoàn Trần Công Danhae06ba62020-04-03 17:28:04 +0700154 stuck to the option without a space. `--no-gpg-sign` is useful to
155 countermand both `commit.gpgSign` configuration variable, and
156 earlier `--gpg-sign`.
Nicolas Vigier3b4e395f2014-02-01 02:18:01 +0000157
Jeff Kingc8089af2010-02-11 17:27:14 -0500158--continue::
Stephan Beyer32402402008-06-08 03:36:09 +0200159-r::
160--resolved::
Junio C Hamano087b6742005-11-16 16:46:24 -0800161 After a patch failure (e.g. attempting to apply
162 conflicting patch), the user has applied it by hand and
163 the index file stores the result of the application.
164 Make a commit using the authorship and commit log
165 extracted from the e-mail message and the current index
166 file, and continue.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200167
Andrew Ruder5c19f242007-04-16 02:21:31 -0500168--resolvemsg=<msg>::
169 When a patch failure occurs, <msg> will be printed
170 to the screen before exiting. This overrides the
Kevin Bracey8ceb6fb2013-06-26 23:06:41 +0300171 standard message informing you to use `--continue`
Andrew Ruder5c19f242007-04-16 02:21:31 -0500172 or `--skip` to handle the failure. This is solely
Thomas Rast0b444cd2010-01-10 00:33:00 +0100173 for internal use between 'git rebase' and 'git am'.
Andrew Ruder5c19f242007-04-16 02:21:31 -0500174
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +0900175--abort::
176 Restore the original branch and abort the patching operation.
177
Nguyễn Thái Ngọc Duy65ed8ff2018-02-14 18:16:06 +0700178--quit::
179 Abort the patching operation but keep HEAD and the index
180 untouched.
181
Paolo Bonziniaa416b22020-02-20 15:15:19 +0100182--show-current-patch[=(diff|raw)]::
183 Show the message at which `git am` has stopped due to
184 conflicts. If `raw` is specified, show the raw contents of
185 the e-mail message; if `diff`, show the diff portion only.
186 Defaults to `raw`.
Nguyễn Thái Ngọc Duy984913a2018-02-11 16:43:26 +0700187
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700188DISCUSSION
189----------
190
Junio C Hamano24998572007-03-24 03:08:54 -0700191The commit author name is taken from the "From: " line of the
Stephen Boyde77063f2009-05-04 22:19:00 -0700192message, and commit author date is taken from the "Date: " line
Junio C Hamano24998572007-03-24 03:08:54 -0700193of the message. The "Subject: " line is used as the title of
194the commit, after stripping common prefix "[PATCH <anything>]".
Stephen Boyd3db964b2009-05-04 22:18:42 -0700195The "Subject: " line is supposed to concisely describe what the
196commit is about in one line of text.
Junio C Hamano24998572007-03-24 03:08:54 -0700197
Paul Menzelf8740c52020-01-03 16:05:46 +0100198"From: ", "Date: ", and "Subject: " lines starting the body override the
199respective commit author name and title values taken from the headers.
Junio C Hamano24998572007-03-24 03:08:54 -0700200
201The commit message is formed by the title taken from the
202"Subject: ", a blank line and the body of the message up to
Stephen Boyd3db964b2009-05-04 22:18:42 -0700203where the patch begins. Excess whitespace at the end of each
204line is automatically stripped.
Junio C Hamano24998572007-03-24 03:08:54 -0700205
206The patch is expected to be inline, directly following the
David J. Mellor07f57462009-03-01 22:37:41 -0800207message. Any line that is of the form:
Junio C Hamano24998572007-03-24 03:08:54 -0700208
209* three-dashes and end-of-line, or
210* a line that begins with "diff -", or
211* a line that begins with "Index: "
212
213is taken as the beginning of a patch, and the commit log message
214is terminated before the first occurrence of such a line.
215
Stephen Boyd3db964b2009-05-04 22:18:42 -0700216When initially invoking `git am`, you give it the names of the mailboxes
David J. Mellor07f57462009-03-01 22:37:41 -0800217to process. Upon seeing the first patch that does not apply, it
218aborts in the middle. You can recover from this in one of two ways:
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700219
Matthieu Moybcf96262016-06-28 13:40:11 +0200220. skip the current patch by re-running the command with the `--skip`
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700221 option.
222
Junio C Hamano087b6742005-11-16 16:46:24 -0800223. hand resolve the conflict in the working directory, and update
David J. Mellor07f57462009-03-01 22:37:41 -0800224 the index file to bring it into a state that the patch should
Matthieu Moybcf96262016-06-28 13:40:11 +0200225 have produced. Then run the command with the `--continue` option.
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700226
SZEDER Gáborb5f306f2011-03-22 19:42:25 +0100227The command refuses to process new mailboxes until the current
228operation is finished, so if you decide to start over from scratch,
229run `git am --abort` before running the command with mailbox
Junio C Hamanobaa720f2005-10-20 22:14:14 -0700230names.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200231
Brian Gernhardt98690992008-07-08 00:12:22 -0400232Before any patches are applied, ORIG_HEAD is set to the tip of the
233current branch. This is useful if you have problems with multiple
234commits, like running 'git am' on the wrong branch or an error in the
235commits that is more easily fixed by changing the mailbox (e.g.
236errors in the "From:" lines).
237
Jonathan Nieder0e3d40c2014-02-24 12:38:29 -0800238HOOKS
239-----
240This command can run `applypatch-msg`, `pre-applypatch`,
241and `post-applypatch` hooks. See linkgit:githooks[5] for more
242information.
Petr Baudis42e2cba2005-10-21 02:28:42 +0200243
244SEE ALSO
245--------
Dan McGee5162e692007-12-29 00:20:38 -0600246linkgit:git-apply[1].
Petr Baudis42e2cba2005-10-21 02:28:42 +0200247
Petr Baudis42e2cba2005-10-21 02:28:42 +0200248GIT
249---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200250Part of the linkgit:git[1] suite