table of contents
- trixie 1:2.47.3-0+deb13u1
- testing 1:2.51.0-1
- unstable 1:2.53.0-1
- experimental 1:2.53.0+next.20260227-1
| GIT-AM(1) | Git Manual | GIT-AM(1) |
NAME¶
git-am - Apply a series of patches from a mailbox
SYNOPSIS¶
git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]verify]
[--[no-]3way] [--interactive] [--committer-date-is-author-date]
[--ignore-date] [--ignore-space-change | --ignore-whitespace]
[--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>]
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
[--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
[--quoted-cr=<action>]
[--empty=(stop|drop|keep)]
[(<mbox> | <Maildir>)...] git am (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty)
DESCRIPTION¶
Splits mail messages in a mailbox into commit log messages, authorship information, and patches, and applies them to the current branch. You could think of it as a reverse operation of git-format-patch(1) run on a branch with a straight history without merges.
OPTIONS¶
(<mbox>|<Maildir>)...
-s, --signoff
-k, --keep
--keep-non-patch
--keep-cr, --no-keep-cr
-c, --scissors
--no-scissors
--quoted-cr=<action>
--empty=(drop|keep|stop)
drop
keep
stop
-m, --message-id
--no-message-id
-q, --quiet
-u, --utf8
This was optional in prior versions of git, but now it is the default. You can use --no-utf8 to override this.
--no-utf8
-3, --3way, --no-3way
--rerere-autoupdate, --no-rerere-autoupdate
--ignore-space-change, --ignore-whitespace, --whitespace=<action>, -C<n>, -p<n>, --directory=<dir>, --exclude=<path>, --include=<path>, --reject
Valid <action> for the --whitespace option are: nowarn, warn, fix, error, and error-all.
--patch-format
-i, --interactive
--verify, -n, --no-verify
Note that post-applypatch cannot be skipped.
--committer-date-is-author-date
Warning
The history walking machinery assumes that commits have non-decreasing commit timestamps. You should consider if you really need to use this option. Then you should only use this option to override the committer date when applying commits on top of a base which commit is older (in terms of the commit date) than the oldest patch you are applying.
--ignore-date
--skip
-S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign
--continue, -r, --resolved
--resolvemsg=<msg>
--abort
--quit
--retry
--show-current-patch[=(diff|raw)]
--allow-empty
DISCUSSION¶
The commit author name is taken from the "From: " line of the message, and commit author date is taken from the "Date: " line of the message. The "Subject: " line is used as the title of the commit, after stripping common prefix "[PATCH <anything>]". The "Subject: " line is supposed to concisely describe what the commit is about in one line of text.
"From: ", "Date: ", and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.
The commit message is formed by the title taken from the "Subject: ", a blank line and the body of the message up to where the patch begins. Excess whitespace at the end of each line is automatically stripped.
The patch is expected to be inline, directly following the message. Any line that is of the form:
is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line.
This means that the contents of the commit message can inadvertently interrupt the processing (see the CAVEATS section below).
When initially invoking git-am(1), you give it the names of the mailboxes to process. Upon seeing the first patch that does not apply, it aborts in the middle. You can recover from this in one of two ways:
The command refuses to process new mailboxes until the current operation is finished, so if you decide to start over from scratch, run git am --abort before running the command with mailbox names.
Before any patches are applied, ORIG_HEAD is set to the tip of the current branch. This is useful if you have problems with multiple commits, like running git-am(1) on the wrong branch or an error in the commits that is more easily fixed by changing the mailbox (e.g. errors in the "From:" lines).
CAVEATS¶
The output from git-format-patch(1) can lead to a different commit message when applied with git-am(1). The patch that is applied may also be different from the one that was generated, or patch application may fail outright. See the DISCUSSION section above for the syntactic rules.
Note that this is especially problematic for unindented diffs that occur in the commit message; the diff in the commit message might get applied along with the patch section, or the patch application machinery might trip up because the patch target doesn’t apply. This could for example be caused by a diff in a Markdown code block.
The solution for this is to indent the diff or other text that could cause problems.
This loss of fidelity might be simple to notice if you are applying patches directly from a mailbox. However, changes originating from Git could be applied in bulk, in which case this would be much harder to notice. This could for example be a Linux distribution which uses patch files to apply changes on top of the commits from the upstream repositories. This goes to show that this behavior does not only impact email workflows.
Given these limitations, one might be tempted to use a general-purpose utility like patch(1) instead. However, patch(1) will not only look for unindented diffs (like git-am(1)) but will try to apply indented diffs as well.
HOOKS¶
This command can run applypatch-msg, pre-applypatch, and post-applypatch hooks. See githooks(5) for more information.
See the --verify/-n/--no-verify options.
CONFIGURATION¶
Everything below this line in this section is selectively included from the git-config(1) documentation. The content is the same as what’s found there:
am.keepcr
am.threeWay
am.messageId
SEE ALSO¶
GIT¶
Part of the git(1) suite
| 03/01/2026 | Git 2.53.0.697.g625c4f |