Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-am(1) |
| 2 | ========= |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 7c73c66 | 2007-01-19 00:37:50 | [diff] [blame] | 6 | git-am - Apply a series of patches from a mailbox |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 12 | 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 13 | [--[no-]3way] [--interactive] [--committer-date-is-author-date] |
Junio C Hamano | fe24db0 | 2009-08-22 05:10:47 | [diff] [blame] | 14 | [--ignore-date] [--ignore-space-change | --ignore-whitespace] |
Junio C Hamano | cc0cb31 | 2009-01-22 03:38:50 | [diff] [blame] | 15 | [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>] |
Junio C Hamano | 0c1b64e | 2012-04-20 23:50:49 | [diff] [blame] | 16 | [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] |
Junio C Hamano | 3214e5f | 2014-03-25 19:54:38 | [diff] [blame] | 17 | [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>] |
Junio C Hamano | 608b11d | 2021-05-16 21:40:45 | [diff] [blame] | 18 | [--quoted-cr=<action>] |
Junio C Hamano | e872a1c | 2022-01-05 22:15:13 | [diff] [blame] | 19 | [--empty=(stop|drop|keep)] |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 20 | [(<mbox> | <Maildir>)...] |
Junio C Hamano | e872a1c | 2022-01-05 22:15:13 | [diff] [blame] | 21 | 'git am' (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)] | --allow-empty) |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 22 | |
| 23 | DESCRIPTION |
| 24 | ----------- |
| 25 | Splits mail messages in a mailbox into commit log message, |
| 26 | authorship information and patches, and applies them to the |
| 27 | current branch. |
| 28 | |
| 29 | OPTIONS |
| 30 | ------- |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 31 | (<mbox>|<Maildir>)...:: |
Junio C Hamano | 9cb74f2 | 2007-02-12 04:15:05 | [diff] [blame] | 32 | The list of mailbox files to read patches from. If you do not |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 33 | supply this argument, the command reads from the standard input. |
| 34 | If you supply directories, they will be treated as Maildirs. |
Junio C Hamano | 9cb74f2 | 2007-02-12 04:15:05 | [diff] [blame] | 35 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 36 | -s:: |
| 37 | --signoff:: |
Junio C Hamano | df3d3cd | 2020-11-02 22:05:05 | [diff] [blame] | 38 | Add a `Signed-off-by` trailer to the commit message, using |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 39 | the committer identity of yourself. |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 40 | See the signoff option in linkgit:git-commit[1] for more information. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 41 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 42 | -k:: |
| 43 | --keep:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 44 | Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 45 | |
Junio C Hamano | b5be052 | 2012-01-29 22:20:19 | [diff] [blame] | 46 | --keep-non-patch:: |
| 47 | Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
| 48 | |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 49 | --[no-]keep-cr:: |
Junio C Hamano | caa712a | 2010-03-11 01:17:35 | [diff] [blame] | 50 | With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1]) |
| 51 | with the same option, to prevent it from stripping CR at the end of |
| 52 | lines. `am.keepcr` configuration variable can be used to specify the |
| 53 | default behaviour. `--no-keep-cr` is useful to override `am.keepcr`. |
| 54 | |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 55 | -c:: |
| 56 | --scissors:: |
| 57 | Remove everything in body before a scissors line (see |
Junio C Hamano | 7f1bc9d | 2015-03-05 22:38:26 | [diff] [blame] | 58 | linkgit:git-mailinfo[1]). Can be activated by default using |
| 59 | the `mailinfo.scissors` configuration variable. |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 60 | |
Junio C Hamano | 01f1fbd | 2010-03-05 07:36:41 | [diff] [blame] | 61 | --no-scissors:: |
Junio C Hamano | cf5b773 | 2009-09-11 23:28:32 | [diff] [blame] | 62 | Ignore scissors lines (see linkgit:git-mailinfo[1]). |
| 63 | |
Junio C Hamano | 608b11d | 2021-05-16 21:40:45 | [diff] [blame] | 64 | --quoted-cr=<action>:: |
| 65 | This flag will be passed down to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
| 66 | |
Junio C Hamano | e872a1c | 2022-01-05 22:15:13 | [diff] [blame] | 67 | --empty=(stop|drop|keep):: |
| 68 | By default, or when the option is set to 'stop', the command |
| 69 | errors out on an input e-mail message lacking a patch |
| 70 | and stops into the middle of the current am session. When this |
| 71 | option is set to 'drop', skip such an e-mail message instead. |
| 72 | When this option is set to 'keep', create an empty commit, |
| 73 | recording the contents of the e-mail message as its log. |
| 74 | |
Junio C Hamano | 6df93d9 | 2014-12-22 22:48:09 | [diff] [blame] | 75 | -m:: |
| 76 | --message-id:: |
| 77 | Pass the `-m` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]), |
| 78 | so that the Message-ID header is added to the commit message. |
| 79 | The `am.messageid` configuration variable can be used to specify |
| 80 | the default behaviour. |
| 81 | |
| 82 | --no-message-id:: |
| 83 | Do not add the Message-ID header to the commit message. |
| 84 | `no-message-id` is useful to override `am.messageid`. |
| 85 | |
Junio C Hamano | 2c14c8d | 2009-07-02 03:17:00 | [diff] [blame] | 86 | -q:: |
| 87 | --quiet:: |
| 88 | Be quiet. Only print error messages. |
| 89 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 90 | -u:: |
| 91 | --utf8:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 92 | Pass `-u` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]). |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 93 | The proposed commit log message taken from the e-mail |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 94 | is re-coded into UTF-8 encoding (configuration variable |
Junio C Hamano | a372d5b | 2021-02-26 01:34:37 | [diff] [blame] | 95 | `i18n.commitEncoding` can be used to specify project's |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 96 | preferred encoding if it is not UTF-8). |
| 97 | + |
| 98 | This was optional in prior versions of git, but now it is the |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 99 | default. You can use `--no-utf8` to override this. |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 100 | |
| 101 | --no-utf8:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 102 | Pass `-n` flag to 'git mailinfo' (see |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 103 | linkgit:git-mailinfo[1]). |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 104 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 105 | -3:: |
| 106 | --3way:: |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 107 | --no-3way:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 108 | When the patch does not apply cleanly, fall back on |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 109 | 3-way merge if the patch records the identity of blobs |
| 110 | it is supposed to apply to and we have those blobs |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 111 | available locally. `--no-3way` can be used to override |
| 112 | am.threeWay configuration variable. For more information, |
| 113 | see am.threeWay in linkgit:git-config[1]. |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 114 | |
Junio C Hamano | 04495a1 | 2022-08-18 21:13:08 | [diff] [blame^] | 115 | include::rerere-options.txt[] |
Junio C Hamano | 6b7d215 | 2019-04-16 12:51:15 | [diff] [blame] | 116 | |
Junio C Hamano | fe24db0 | 2009-08-22 05:10:47 | [diff] [blame] | 117 | --ignore-space-change:: |
| 118 | --ignore-whitespace:: |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 119 | --whitespace=<option>:: |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 120 | -C<n>:: |
| 121 | -p<n>:: |
Junio C Hamano | cc0cb31 | 2009-01-22 03:38:50 | [diff] [blame] | 122 | --directory=<dir>:: |
Junio C Hamano | dac21e7 | 2011-08-19 06:50:43 | [diff] [blame] | 123 | --exclude=<path>:: |
Junio C Hamano | 0c1b64e | 2012-04-20 23:50:49 | [diff] [blame] | 124 | --include=<path>:: |
Junio C Hamano | 22bcc11 | 2009-01-24 08:05:18 | [diff] [blame] | 125 | --reject:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 126 | These flags are passed to the 'git apply' (see linkgit:git-apply[1]) |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 127 | program that applies |
| 128 | the patch. |
| 129 | |
Junio C Hamano | 3214e5f | 2014-03-25 19:54:38 | [diff] [blame] | 130 | --patch-format:: |
| 131 | By default the command will try to detect the patch format |
| 132 | automatically. This option allows the user to bypass the automatic |
| 133 | detection and specify the patch format that the patch(es) should be |
Junio C Hamano | c6c919b | 2016-07-06 21:34:15 | [diff] [blame] | 134 | interpreted as. Valid formats are mbox, mboxrd, |
| 135 | stgit, stgit-series and hg. |
Junio C Hamano | 3214e5f | 2014-03-25 19:54:38 | [diff] [blame] | 136 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 137 | -i:: |
| 138 | --interactive:: |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 139 | Run interactively. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 140 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 141 | --committer-date-is-author-date:: |
| 142 | By default the command records the date from the e-mail |
| 143 | message as the commit author date, and uses the time of |
| 144 | commit creation as the committer date. This allows the |
| 145 | user to lie about the committer date by using the same |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 146 | value as the author date. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 147 | |
| 148 | --ignore-date:: |
| 149 | By default the command records the date from the e-mail |
| 150 | message as the commit author date, and uses the time of |
| 151 | commit creation as the committer date. This allows the |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 152 | user to lie about the author date by using the same |
| 153 | value as the committer date. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 154 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 155 | --skip:: |
| 156 | Skip the current patch. This is only meaningful when |
| 157 | restarting an aborted patch. |
| 158 | |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 159 | -S[<keyid>]:: |
| 160 | --gpg-sign[=<keyid>]:: |
Junio C Hamano | 67bf224 | 2020-04-22 21:41:44 | [diff] [blame] | 161 | --no-gpg-sign:: |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 162 | GPG-sign commits. The `keyid` argument is optional and |
| 163 | defaults to the committer identity; if specified, it must be |
Junio C Hamano | 67bf224 | 2020-04-22 21:41:44 | [diff] [blame] | 164 | stuck to the option without a space. `--no-gpg-sign` is useful to |
| 165 | countermand both `commit.gpgSign` configuration variable, and |
| 166 | earlier `--gpg-sign`. |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 167 | |
Junio C Hamano | b2628b1 | 2010-02-12 08:08:08 | [diff] [blame] | 168 | --continue:: |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 169 | -r:: |
| 170 | --resolved:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 171 | After a patch failure (e.g. attempting to apply |
| 172 | conflicting patch), the user has applied it by hand and |
| 173 | the index file stores the result of the application. |
| 174 | Make a commit using the authorship and commit log |
| 175 | extracted from the e-mail message and the current index |
| 176 | file, and continue. |
| 177 | |
Junio C Hamano | 0e3cb53 | 2007-04-17 08:28:11 | [diff] [blame] | 178 | --resolvemsg=<msg>:: |
| 179 | When a patch failure occurs, <msg> will be printed |
| 180 | to the screen before exiting. This overrides the |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 181 | standard message informing you to use `--continue` |
Junio C Hamano | 0e3cb53 | 2007-04-17 08:28:11 | [diff] [blame] | 182 | or `--skip` to handle the failure. This is solely |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 183 | for internal use between 'git rebase' and 'git am'. |
Junio C Hamano | 0e3cb53 | 2007-04-17 08:28:11 | [diff] [blame] | 184 | |
Junio C Hamano | 5ba2c22 | 2008-07-21 04:33:46 | [diff] [blame] | 185 | --abort:: |
| 186 | Restore the original branch and abort the patching operation. |
Junio C Hamano | eb4d567 | 2021-09-23 21:35:54 | [diff] [blame] | 187 | Revert contents of files involved in the am operation to their |
| 188 | pre-am state. |
Junio C Hamano | 5ba2c22 | 2008-07-21 04:33:46 | [diff] [blame] | 189 | |
Junio C Hamano | 615c3b3 | 2018-02-28 23:40:27 | [diff] [blame] | 190 | --quit:: |
| 191 | Abort the patching operation but keep HEAD and the index |
| 192 | untouched. |
| 193 | |
Junio C Hamano | 35a5155 | 2020-03-10 06:08:58 | [diff] [blame] | 194 | --show-current-patch[=(diff|raw)]:: |
| 195 | Show the message at which `git am` has stopped due to |
| 196 | conflicts. If `raw` is specified, show the raw contents of |
| 197 | the e-mail message; if `diff`, show the diff portion only. |
| 198 | Defaults to `raw`. |
Junio C Hamano | 664750f | 2018-03-06 23:25:44 | [diff] [blame] | 199 | |
Junio C Hamano | e872a1c | 2022-01-05 22:15:13 | [diff] [blame] | 200 | --allow-empty:: |
| 201 | After a patch failure on an input e-mail message lacking a patch, |
| 202 | create an empty commit with the contents of the e-mail message |
| 203 | as its log message. |
| 204 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 205 | DISCUSSION |
| 206 | ---------- |
| 207 | |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 208 | The commit author name is taken from the "From: " line of the |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 209 | message, and commit author date is taken from the "Date: " line |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 210 | of the message. The "Subject: " line is used as the title of |
| 211 | the commit, after stripping common prefix "[PATCH <anything>]". |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 212 | The "Subject: " line is supposed to concisely describe what the |
| 213 | commit is about in one line of text. |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 214 | |
Junio C Hamano | 9d828c9 | 2020-01-08 21:18:22 | [diff] [blame] | 215 | "From: ", "Date: ", and "Subject: " lines starting the body override the |
| 216 | respective commit author name and title values taken from the headers. |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 217 | |
| 218 | The commit message is formed by the title taken from the |
| 219 | "Subject: ", a blank line and the body of the message up to |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 220 | where the patch begins. Excess whitespace at the end of each |
| 221 | line is automatically stripped. |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 222 | |
| 223 | The patch is expected to be inline, directly following the |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 224 | message. Any line that is of the form: |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 225 | |
| 226 | * three-dashes and end-of-line, or |
| 227 | * a line that begins with "diff -", or |
| 228 | * a line that begins with "Index: " |
| 229 | |
| 230 | is taken as the beginning of a patch, and the commit log message |
| 231 | is terminated before the first occurrence of such a line. |
| 232 | |
Junio C Hamano | 86f3157 | 2009-05-06 07:38:42 | [diff] [blame] | 233 | When initially invoking `git am`, you give it the names of the mailboxes |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 234 | to process. Upon seeing the first patch that does not apply, it |
| 235 | aborts in the middle. You can recover from this in one of two ways: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 236 | |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 237 | . skip the current patch by re-running the command with the `--skip` |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 238 | option. |
| 239 | |
| 240 | . hand resolve the conflict in the working directory, and update |
Junio C Hamano | 7924d5e | 2009-03-03 08:28:48 | [diff] [blame] | 241 | the index file to bring it into a state that the patch should |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 242 | have produced. Then run the command with the `--continue` option. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 243 | |
Junio C Hamano | 78f25df | 2011-03-23 00:05:35 | [diff] [blame] | 244 | The command refuses to process new mailboxes until the current |
| 245 | operation is finished, so if you decide to start over from scratch, |
| 246 | run `git am --abort` before running the command with mailbox |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 247 | names. |
| 248 | |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 249 | Before any patches are applied, ORIG_HEAD is set to the tip of the |
| 250 | current branch. This is useful if you have problems with multiple |
| 251 | commits, like running 'git am' on the wrong branch or an error in the |
| 252 | commits that is more easily fixed by changing the mailbox (e.g. |
| 253 | errors in the "From:" lines). |
| 254 | |
Junio C Hamano | 81703b2 | 2014-03-14 22:00:27 | [diff] [blame] | 255 | HOOKS |
| 256 | ----- |
| 257 | This command can run `applypatch-msg`, `pre-applypatch`, |
| 258 | and `post-applypatch` hooks. See linkgit:githooks[5] for more |
| 259 | information. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 260 | |
| 261 | SEE ALSO |
| 262 | -------- |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 263 | linkgit:git-apply[1]. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 264 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 265 | GIT |
| 266 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 267 | Part of the linkgit:git[1] suite |