Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 1 | git-am(1) |
Junio C Hamano | 05625af | 2005-10-21 20:57:34 -0700 | [diff] [blame] | 2 | ========= |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | c3f0baa | 2007-01-18 15:53:37 -0800 | [diff] [blame] | 6 | git-am - Apply a series of patches from a mailbox |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Jonas Fonseca | 353ce81 | 2005-12-31 18:37:15 +0100 | [diff] [blame] | 11 | [verse] |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 12 | 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] |
Remi Lespinet | e97a5e7 | 2015-08-04 22:19:26 +0800 | [diff] [blame] | 13 | [--[no-]3way] [--interactive] [--committer-date-is-author-date] |
Giuseppe Bilotta | 86c91f9 | 2009-08-04 13:16:49 +0200 | [diff] [blame] | 14 | [--ignore-date] [--ignore-space-change | --ignore-whitespace] |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 15 | [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>] |
Johannes Berg | 58725ef | 2012-03-28 13:11:28 +0200 | [diff] [blame] | 16 | [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] |
Junio C Hamano | 2dfefe0 | 2014-03-25 11:01:31 -0700 | [diff] [blame] | 17 | [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>] |
Štěpán Němec | 0adda93 | 2010-10-08 19:31:17 +0200 | [diff] [blame] | 18 | [(<mbox> | <Maildir>)...] |
Junio C Hamano | 9ca488c | 2018-03-06 14:54:02 -0800 | [diff] [blame] | 19 | 'git am' (--continue | --skip | --abort | --quit | --show-current-patch) |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 20 | |
| 21 | DESCRIPTION |
| 22 | ----------- |
| 23 | Splits mail messages in a mailbox into commit log message, |
| 24 | authorship information and patches, and applies them to the |
| 25 | current branch. |
| 26 | |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 27 | OPTIONS |
| 28 | ------- |
Štěpán Němec | 0adda93 | 2010-10-08 19:31:17 +0200 | [diff] [blame] | 29 | (<mbox>|<Maildir>)...:: |
Michael S. Tsirkin | d414461 | 2007-02-09 12:23:23 +0200 | [diff] [blame] | 30 | The list of mailbox files to read patches from. If you do not |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 31 | supply this argument, the command reads from the standard input. |
| 32 | If you supply directories, they will be treated as Maildirs. |
Michael S. Tsirkin | d414461 | 2007-02-09 12:23:23 +0200 | [diff] [blame] | 33 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 34 | -s:: |
| 35 | --signoff:: |
Stephen Boyd | 3db964b | 2009-05-04 22:18:42 -0700 | [diff] [blame] | 36 | Add a `Signed-off-by:` line to the commit message, using |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 37 | the committer identity of yourself. |
David A. Wheeler | b2c150d | 2016-01-05 14:20:26 -0500 | [diff] [blame] | 38 | See the signoff option in linkgit:git-commit[1] for more information. |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 39 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 40 | -k:: |
| 41 | --keep:: |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 42 | Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
Junio C Hamano | d84029b | 2007-01-08 13:59:15 -0800 | [diff] [blame] | 43 | |
Thomas Rast | f7e5ea1 | 2012-01-16 11:53:00 +0100 | [diff] [blame] | 44 | --keep-non-patch:: |
| 45 | Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
| 46 | |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 47 | --[no-]keep-cr:: |
Stefan-W. Hahn | ad2c928 | 2010-02-27 15:20:26 +0100 | [diff] [blame] | 48 | 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. Hahn | e80d4cb | 2010-02-27 15:20:27 +0100 | [diff] [blame] | 50 | 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. Hahn | ad2c928 | 2010-02-27 15:20:26 +0100 | [diff] [blame] | 52 | |
Junio C Hamano | 017678b | 2009-08-26 21:36:05 -0700 | [diff] [blame] | 53 | -c:: |
| 54 | --scissors:: |
| 55 | Remove everything in body before a scissors line (see |
Matthieu Moy | afb5de7 | 2015-02-20 20:32:21 +0100 | [diff] [blame] | 56 | linkgit:git-mailinfo[1]). Can be activated by default using |
| 57 | the `mailinfo.scissors` configuration variable. |
Junio C Hamano | 017678b | 2009-08-26 21:36:05 -0700 | [diff] [blame] | 58 | |
Michal Sojka | 8024d59 | 2010-03-04 13:08:28 +0100 | [diff] [blame] | 59 | --no-scissors:: |
Nicolas Sebrecht | 434a6db | 2009-09-11 02:29:58 +0200 | [diff] [blame] | 60 | Ignore scissors lines (see linkgit:git-mailinfo[1]). |
| 61 | |
Paolo Bonzini | a078f73 | 2014-11-25 15:00:56 +0100 | [diff] [blame] | 62 | -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 Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 73 | -q:: |
| 74 | --quiet:: |
| 75 | Be quiet. Only print error messages. |
| 76 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 77 | -u:: |
| 78 | --utf8:: |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 79 | Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
Junio C Hamano | d84029b | 2007-01-08 13:59:15 -0800 | [diff] [blame] | 80 | The proposed commit log message taken from the e-mail |
Frank Lichtenheld | 870e0d6 | 2007-05-14 16:44:53 +0200 | [diff] [blame] | 81 | is re-coded into UTF-8 encoding (configuration variable |
Junio C Hamano | d84029b | 2007-01-08 13:59:15 -0800 | [diff] [blame] | 82 | `i18n.commitencoding` can be used to specify project's |
| 83 | preferred encoding if it is not UTF-8). |
| 84 | + |
| 85 | This was optional in prior versions of git, but now it is the |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 86 | default. You can use `--no-utf8` to override this. |
Junio C Hamano | d84029b | 2007-01-08 13:59:15 -0800 | [diff] [blame] | 87 | |
| 88 | --no-utf8:: |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 89 | Pass `-n` flag to 'git mailinfo' (see |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 90 | linkgit:git-mailinfo[1]). |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 91 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 92 | -3:: |
| 93 | --3way:: |
Remi Lespinet | e97a5e7 | 2015-08-04 22:19:26 +0800 | [diff] [blame] | 94 | --no-3way:: |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 95 | When the patch does not apply cleanly, fall back on |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 96 | 3-way merge if the patch records the identity of blobs |
| 97 | it is supposed to apply to and we have those blobs |
Remi Lespinet | e97a5e7 | 2015-08-04 22:19:26 +0800 | [diff] [blame] | 98 | 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 Lichtenheld | 870e0d6 | 2007-05-14 16:44:53 +0200 | [diff] [blame] | 101 | |
Giuseppe Bilotta | 86c91f9 | 2009-08-04 13:16:49 +0200 | [diff] [blame] | 102 | --ignore-space-change:: |
| 103 | --ignore-whitespace:: |
Frank Lichtenheld | 870e0d6 | 2007-05-14 16:44:53 +0200 | [diff] [blame] | 104 | --whitespace=<option>:: |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 105 | -C<n>:: |
| 106 | -p<n>:: |
Junio C Hamano | b47dfe9 | 2009-01-11 22:21:48 -0800 | [diff] [blame] | 107 | --directory=<dir>:: |
maximilian attems | 2ae7345 | 2011-08-09 17:21:08 +0200 | [diff] [blame] | 108 | --exclude=<path>:: |
Johannes Berg | 58725ef | 2012-03-28 13:11:28 +0200 | [diff] [blame] | 109 | --include=<path>:: |
martin f. krafft | b80da42 | 2009-01-23 11:31:21 +1100 | [diff] [blame] | 110 | --reject:: |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 111 | These flags are passed to the 'git apply' (see linkgit:git-apply[1]) |
Frank Lichtenheld | 870e0d6 | 2007-05-14 16:44:53 +0200 | [diff] [blame] | 112 | program that applies |
| 113 | the patch. |
| 114 | |
Chris Packham | 6498137 | 2014-03-11 16:51:57 +1300 | [diff] [blame] | 115 | --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 Wong | d9925d1 | 2016-06-05 04:46:41 +0000 | [diff] [blame] | 119 | interpreted as. Valid formats are mbox, mboxrd, |
| 120 | stgit, stgit-series and hg. |
Chris Packham | 6498137 | 2014-03-11 16:51:57 +1300 | [diff] [blame] | 121 | |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 122 | -i:: |
| 123 | --interactive:: |
Frank Lichtenheld | 870e0d6 | 2007-05-14 16:44:53 +0200 | [diff] [blame] | 124 | Run interactively. |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 125 | |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 126 | --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 Boyd | e77063f | 2009-05-04 22:19:00 -0700 | [diff] [blame] | 131 | value as the author date. |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 132 | |
| 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 Boyd | e77063f | 2009-05-04 22:19:00 -0700 | [diff] [blame] | 137 | user to lie about the author date by using the same |
| 138 | value as the committer date. |
Nanako Shiraishi | a79ec62 | 2009-01-24 10:18:02 +0900 | [diff] [blame] | 139 | |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 140 | --skip:: |
| 141 | Skip the current patch. This is only meaningful when |
| 142 | restarting an aborted patch. |
| 143 | |
Nicolas Vigier | 3b4e395f | 2014-02-01 02:18:01 +0000 | [diff] [blame] | 144 | -S[<keyid>]:: |
| 145 | --gpg-sign[=<keyid>]:: |
Matthieu Moy | 2b594bf | 2015-09-19 09:47:50 +0200 | [diff] [blame] | 146 | 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 Vigier | 3b4e395f | 2014-02-01 02:18:01 +0000 | [diff] [blame] | 149 | |
Jeff King | c8089af | 2010-02-11 17:27:14 -0500 | [diff] [blame] | 150 | --continue:: |
Stephan Beyer | 3240240 | 2008-06-08 03:36:09 +0200 | [diff] [blame] | 151 | -r:: |
| 152 | --resolved:: |
Junio C Hamano | 087b674 | 2005-11-16 16:46:24 -0800 | [diff] [blame] | 153 | 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 Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 159 | |
Andrew Ruder | 5c19f24 | 2007-04-16 02:21:31 -0500 | [diff] [blame] | 160 | --resolvemsg=<msg>:: |
| 161 | When a patch failure occurs, <msg> will be printed |
| 162 | to the screen before exiting. This overrides the |
Kevin Bracey | 8ceb6fb | 2013-06-26 23:06:41 +0300 | [diff] [blame] | 163 | standard message informing you to use `--continue` |
Andrew Ruder | 5c19f24 | 2007-04-16 02:21:31 -0500 | [diff] [blame] | 164 | or `--skip` to handle the failure. This is solely |
Thomas Rast | 0b444cd | 2010-01-10 00:33:00 +0100 | [diff] [blame] | 165 | for internal use between 'git rebase' and 'git am'. |
Andrew Ruder | 5c19f24 | 2007-04-16 02:21:31 -0500 | [diff] [blame] | 166 | |
Nanako Shiraishi | 3e5057a | 2008-07-16 19:39:10 +0900 | [diff] [blame] | 167 | --abort:: |
| 168 | Restore the original branch and abort the patching operation. |
| 169 | |
Nguyễn Thái Ngọc Duy | 65ed8ff | 2018-02-14 18:16:06 +0700 | [diff] [blame] | 170 | --quit:: |
| 171 | Abort the patching operation but keep HEAD and the index |
| 172 | untouched. |
| 173 | |
Nguyễn Thái Ngọc Duy | 984913a | 2018-02-11 16:43:26 +0700 | [diff] [blame] | 174 | --show-current-patch:: |
| 175 | Show the patch being applied when "git am" is stopped because |
| 176 | of conflicts. |
| 177 | |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 178 | DISCUSSION |
| 179 | ---------- |
| 180 | |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 181 | The commit author name is taken from the "From: " line of the |
Stephen Boyd | e77063f | 2009-05-04 22:19:00 -0700 | [diff] [blame] | 182 | message, and commit author date is taken from the "Date: " line |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 183 | of the message. The "Subject: " line is used as the title of |
| 184 | the commit, after stripping common prefix "[PATCH <anything>]". |
Stephen Boyd | 3db964b | 2009-05-04 22:18:42 -0700 | [diff] [blame] | 185 | The "Subject: " line is supposed to concisely describe what the |
| 186 | commit is about in one line of text. |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 187 | |
Nanako Shiraishi | f43c97f | 2009-08-25 17:20:00 +0900 | [diff] [blame] | 188 | "From: " and "Subject: " lines starting the body override the respective |
| 189 | commit author name and title values taken from the headers. |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 190 | |
| 191 | The commit message is formed by the title taken from the |
| 192 | "Subject: ", a blank line and the body of the message up to |
Stephen Boyd | 3db964b | 2009-05-04 22:18:42 -0700 | [diff] [blame] | 193 | where the patch begins. Excess whitespace at the end of each |
| 194 | line is automatically stripped. |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 195 | |
| 196 | The patch is expected to be inline, directly following the |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 197 | message. Any line that is of the form: |
Junio C Hamano | 2499857 | 2007-03-24 03:08:54 -0700 | [diff] [blame] | 198 | |
| 199 | * three-dashes and end-of-line, or |
| 200 | * a line that begins with "diff -", or |
| 201 | * a line that begins with "Index: " |
| 202 | |
| 203 | is taken as the beginning of a patch, and the commit log message |
| 204 | is terminated before the first occurrence of such a line. |
| 205 | |
Stephen Boyd | 3db964b | 2009-05-04 22:18:42 -0700 | [diff] [blame] | 206 | When initially invoking `git am`, you give it the names of the mailboxes |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 207 | to process. Upon seeing the first patch that does not apply, it |
| 208 | aborts in the middle. You can recover from this in one of two ways: |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 209 | |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 210 | . skip the current patch by re-running the command with the `--skip` |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 211 | option. |
| 212 | |
Junio C Hamano | 087b674 | 2005-11-16 16:46:24 -0800 | [diff] [blame] | 213 | . hand resolve the conflict in the working directory, and update |
David J. Mellor | 07f5746 | 2009-03-01 22:37:41 -0800 | [diff] [blame] | 214 | the index file to bring it into a state that the patch should |
Matthieu Moy | bcf9626 | 2016-06-28 13:40:11 +0200 | [diff] [blame] | 215 | have produced. Then run the command with the `--continue` option. |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 216 | |
SZEDER Gábor | b5f306f | 2011-03-22 19:42:25 +0100 | [diff] [blame] | 217 | The command refuses to process new mailboxes until the current |
| 218 | operation is finished, so if you decide to start over from scratch, |
| 219 | run `git am --abort` before running the command with mailbox |
Junio C Hamano | baa720f | 2005-10-20 22:14:14 -0700 | [diff] [blame] | 220 | names. |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 221 | |
Brian Gernhardt | 9869099 | 2008-07-08 00:12:22 -0400 | [diff] [blame] | 222 | Before any patches are applied, ORIG_HEAD is set to the tip of the |
| 223 | current branch. This is useful if you have problems with multiple |
| 224 | commits, like running 'git am' on the wrong branch or an error in the |
| 225 | commits that is more easily fixed by changing the mailbox (e.g. |
| 226 | errors in the "From:" lines). |
| 227 | |
Jonathan Nieder | 0e3d40c | 2014-02-24 12:38:29 -0800 | [diff] [blame] | 228 | HOOKS |
| 229 | ----- |
| 230 | This command can run `applypatch-msg`, `pre-applypatch`, |
| 231 | and `post-applypatch` hooks. See linkgit:githooks[5] for more |
| 232 | information. |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 233 | |
| 234 | SEE ALSO |
| 235 | -------- |
Dan McGee | 5162e69 | 2007-12-29 00:20:38 -0600 | [diff] [blame] | 236 | linkgit:git-apply[1]. |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 237 | |
Petr Baudis | 42e2cba | 2005-10-21 02:28:42 +0200 | [diff] [blame] | 238 | GIT |
| 239 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 240 | Part of the linkgit:git[1] suite |