git am: Usage, Options & Common CI Errors
git am replays a mailbox of patches, creating a commit for each - the counterpart to format-patch.
am applies emailed or generated patch series back into history as real commits, preserving authorship.
What it does
git am reads patches in mailbox format (from format-patch or an mbox) and applies each as a commit on the current branch, keeping the original author and message.
Common usage
Terminal
git am series.mbox
git am --3way series.mbox # 3-way merge on conflict
git am < patch.eml
# after fixing a conflict:
git add <file> && git am --continue
git am --abortOptions
| Flag | What it does |
|---|---|
| --3way / -3 | Fall back to 3-way merge |
| --continue | Resume after resolving conflicts |
| --skip | Skip the current patch |
| --abort | Restore the pre-am state |
| -s / --signoff | Add a Signed-off-by line |
Common errors in CI
error: "Patch failed at 0001 …" with "hint: Use git am --show-current-patch to see the failed patch" - the patch did not apply cleanly. Try --3way, resolve and --continue, --skip to drop it, or --abort to bail out.
Related guides
git format-patch: Usage, Options & Common CI Errorsgit format-patch turns commits into mailbox patch files for review or git am. Reference for -N, --stdout, --c…
git apply: Usage, Options & Common CI Errorsgit apply applies a patch file to the working tree or index. Reference for --check, --3way, --index, -p, and…
git cherry-pick: Usage, Options & Common CI Errorsgit cherry-pick applies the changes from specific commits onto the current branch. Reference for -x, -n, rang…
git rebase: Usage, Options & Common CI Errorsgit rebase replays commits onto a new base to keep history linear. Reference for -i, --onto, --continue, --ab…