1GIT-AM(1) Git Manual GIT-AM(1)
2
3
4
6 git-am - Apply a series of patches from a mailbox
7
9 git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--no-verify]
10 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
11 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
12 [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>]
13 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
14 [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
15 [--quoted-cr=<action>]
16 [--empty=(stop|drop|keep)]
17 [(<mbox> | <Maildir>)...]
18 git am (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)] | --allow-empty)
19
21 Splits mail messages in a mailbox into commit log messages, authorship
22 information, and patches, and applies them to the current branch. You
23 could think of it as a reverse operation of git-format-patch(1) run on
24 a branch with a straight history without merges.
25
27 (<mbox>|<Maildir>)...
28 The list of mailbox files to read patches from. If you do not
29 supply this argument, the command reads from the standard input. If
30 you supply directories, they will be treated as Maildirs.
31
32 -s, --signoff
33 Add a Signed-off-by trailer to the commit message, using the
34 committer identity of yourself. See the signoff option in git-
35 commit(1) for more information.
36
37 -k, --keep
38 Pass -k flag to git mailinfo (see git-mailinfo(1)).
39
40 --keep-non-patch
41 Pass -b flag to git mailinfo (see git-mailinfo(1)).
42
43 --[no-]keep-cr
44 With --keep-cr, call git mailsplit (see git-mailsplit(1)) with the
45 same option, to prevent it from stripping CR at the end of lines.
46 am.keepcr configuration variable can be used to specify the default
47 behaviour. --no-keep-cr is useful to override am.keepcr.
48
49 -c, --scissors
50 Remove everything in body before a scissors line (see git-
51 mailinfo(1)). Can be activated by default using the
52 mailinfo.scissors configuration variable.
53
54 --no-scissors
55 Ignore scissors lines (see git-mailinfo(1)).
56
57 --quoted-cr=<action>
58 This flag will be passed down to git mailinfo (see git-
59 mailinfo(1)).
60
61 --empty=(stop|drop|keep)
62 By default, or when the option is set to stop, the command errors
63 out on an input e-mail message lacking a patch and stops in the
64 middle of the current am session. When this option is set to drop,
65 skip such an e-mail message instead. When this option is set to
66 keep, create an empty commit, recording the contents of the e-mail
67 message as its log.
68
69 -m, --message-id
70 Pass the -m flag to git mailinfo (see git-mailinfo(1)), so that the
71 Message-ID header is added to the commit message. The am.messageid
72 configuration variable can be used to specify the default
73 behaviour.
74
75 --no-message-id
76 Do not add the Message-ID header to the commit message.
77 no-message-id is useful to override am.messageid.
78
79 -q, --quiet
80 Be quiet. Only print error messages.
81
82 -u, --utf8
83 Pass -u flag to git mailinfo (see git-mailinfo(1)). The proposed
84 commit log message taken from the e-mail is re-coded into UTF-8
85 encoding (configuration variable i18n.commitEncoding can be used to
86 specify the project’s preferred encoding if it is not UTF-8).
87
88 This was optional in prior versions of git, but now it is the
89 default. You can use --no-utf8 to override this.
90
91 --no-utf8
92 Pass -n flag to git mailinfo (see git-mailinfo(1)).
93
94 -3, --3way, --no-3way
95 When the patch does not apply cleanly, fall back on 3-way merge if
96 the patch records the identity of blobs it is supposed to apply to
97 and we have those blobs available locally. --no-3way can be used
98 to override am.threeWay configuration variable. For more
99 information, see am.threeWay in git-config(1).
100
101 --rerere-autoupdate, --no-rerere-autoupdate
102 After the rerere mechanism reuses a recorded resolution on the
103 current conflict to update the files in the working tree, allow it
104 to also update the index with the result of resolution.
105 --no-rerere-autoupdate is a good way to double-check what rerere
106 did and catch potential mismerges, before committing the result to
107 the index with a separate git add.
108
109 --ignore-space-change, --ignore-whitespace, --whitespace=<action>,
110 -C<n>, -p<n>, --directory=<dir>, --exclude=<path>, --include=<path>,
111 --reject
112 These flags are passed to the git apply (see git-apply(1)) program
113 that applies the patch.
114
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
119 interpreted as. Valid formats are mbox, mboxrd, stgit,
120 stgit-series, and hg.
121
122 -i, --interactive
123 Run interactively.
124
125 -n, --no-verify
126 By default, the pre-applypatch and applypatch-msg hooks are run.
127 When any of --no-verify or -n is given, these are bypassed. See
128 also githooks(5).
129
130 --committer-date-is-author-date
131 By default the command records the date from the e-mail message as
132 the commit author date, and uses the time of commit creation as the
133 committer date. This allows the user to lie about the committer
134 date by using the same value as the author date.
135
136 --ignore-date
137 By default the command records the date from the e-mail message as
138 the commit author date, and uses the time of commit creation as the
139 committer date. This allows the user to lie about the author date
140 by using the same value as the committer date.
141
142 --skip
143 Skip the current patch. This is only meaningful when restarting an
144 aborted patch.
145
146 -S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign
147 GPG-sign commits. The keyid argument is optional and defaults to
148 the committer identity; if specified, it must be stuck to the
149 option without a space. --no-gpg-sign is useful to countermand
150 both commit.gpgSign configuration variable, and earlier --gpg-sign.
151
152 --continue, -r, --resolved
153 After a patch failure (e.g. attempting to apply conflicting patch),
154 the user has applied it by hand and the index file stores the
155 result of the application. Make a commit using the authorship and
156 commit log extracted from the e-mail message and the current index
157 file, and continue.
158
159 --resolvemsg=<msg>
160 When a patch failure occurs, <msg> will be printed to the screen
161 before exiting. This overrides the standard message informing you
162 to use --continue or --skip to handle the failure. This is solely
163 for internal use between git rebase and git am.
164
165 --abort
166 Restore the original branch and abort the patching operation.
167 Revert the contents of files involved in the am operation to their
168 pre-am state.
169
170 --quit
171 Abort the patching operation but keep HEAD and the index untouched.
172
173 --show-current-patch[=(diff|raw)]
174 Show the message at which git am has stopped due to conflicts. If
175 raw is specified, show the raw contents of the e-mail message; if
176 diff, show the diff portion only. Defaults to raw.
177
178 --allow-empty
179 After a patch failure on an input e-mail message lacking a patch,
180 create an empty commit with the contents of the e-mail message as
181 its log message.
182
184 The commit author name is taken from the "From: " line of the message,
185 and commit author date is taken from the "Date: " line of the message.
186 The "Subject: " line is used as the title of the commit, after
187 stripping common prefix "[PATCH <anything>]". The "Subject: " line is
188 supposed to concisely describe what the commit is about in one line of
189 text.
190
191 "From: ", "Date: ", and "Subject: " lines starting the body override
192 the respective commit author name and title values taken from the
193 headers.
194
195 The commit message is formed by the title taken from the "Subject: ", a
196 blank line and the body of the message up to where the patch begins.
197 Excess whitespace at the end of each line is automatically stripped.
198
199 The patch is expected to be inline, directly following the message. Any
200 line that is of the form:
201
202 • three-dashes and end-of-line, or
203
204 • a line that begins with "diff -", or
205
206 • a line that begins with "Index: "
207
208 is taken as the beginning of a patch, and the commit log message is
209 terminated before the first occurrence of such a line.
210
211 When initially invoking git am, you give it the names of the mailboxes
212 to process. Upon seeing the first patch that does not apply, it aborts
213 in the middle. You can recover from this in one of two ways:
214
215 1. skip the current patch by re-running the command with the --skip
216 option.
217
218 2. hand resolve the conflict in the working directory, and update the
219 index file to bring it into a state that the patch should have
220 produced. Then run the command with the --continue option.
221
222 The command refuses to process new mailboxes until the current
223 operation is finished, so if you decide to start over from scratch, run
224 git am --abort before running the command with mailbox names.
225
226 Before any patches are applied, ORIG_HEAD is set to the tip of the
227 current branch. This is useful if you have problems with multiple
228 commits, like running git am on the wrong branch or an error in the
229 commits that is more easily fixed by changing the mailbox (e.g. errors
230 in the "From:" lines).
231
233 This command can run applypatch-msg, pre-applypatch, and
234 post-applypatch hooks. See githooks(5) for more information.
235
237 Everything below this line in this section is selectively included from
238 the git-config(1) documentation. The content is the same as what’s
239 found there:
240
241 am.keepcr
242 If true, git-am will call git-mailsplit for patches in mbox format
243 with parameter --keep-cr. In this case git-mailsplit will not
244 remove \r from lines ending with \r\n. Can be overridden by giving
245 --no-keep-cr from the command line. See git-am(1), git-
246 mailsplit(1).
247
248 am.threeWay
249 By default, git am will fail if the patch does not apply cleanly.
250 When set to true, this setting tells git am to fall back on 3-way
251 merge if the patch records the identity of blobs it is supposed to
252 apply to and we have those blobs available locally (equivalent to
253 giving the --3way option from the command line). Defaults to false.
254 See git-am(1).
255
257 git-apply(1), git-format-patch(1).
258
260 Part of the git(1) suite
261
262
263
264Git 2.43.0 11/20/2023 GIT-AM(1)