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