Skip to content

am Git Command Guide

The git am command applies patches from email messages (in mbox format) to the current branch. It is commonly used for applying patches received via email, such as those from mailing lists. It can handle multiple patches and supports resolving conflicts interactively.

Terminal window
git am [options] [<mbox>|<Maildir>...]
git am [options] --continue | --skip | --abort
OptionDescription
-3, —3wayFall back to 3-way merge if patch doesn’t apply cleanly
—abortRestore the original branch and abort the patching operation
—continueContinue after resolving conflicts
-s, —signoffAdd a Signed-off-by line to the commit
—skipSkip the current patch
-r, —resolvedMark conflicts as resolved after manual editing
-CEnsure at least n lines of surrounding context
—whitespace=Handle whitespace errors
-pStrip n leading components from patch paths
—interactiveApply patches interactively
ParameterDescription
mboxFile containing patches in mbox format
MaildirDirectory containing patches as individual files
Terminal window
git am patches.mbox

Applies all patches in the specified mbox file to the current branch.

Terminal window
git am --signoff --3way 0001-patch.patch

Applies the patch with a Signed-off-by line and falls back to three-way merge on conflicts.

Terminal window
git am --abort

Restores the branch to its state before starting the am operation.

Terminal window
git am --continue

After manually resolving conflicts, continue applying remaining patches.

Terminal window
git am --interactive patches/

Prompt for confirmation before applying each patch in the directory.

To apply patches using git am, use the following command:

Terminal window
git am <patch-file>

How can I apply multiple patches in a directory with git am?

Section titled “How can I apply multiple patches in a directory with git am?”

To apply multiple patches in a directory, you can use:

Terminal window
git am <directory>/

How do I handle conflicts when using git am?

Section titled “How do I handle conflicts when using git am?”

To handle conflicts when applying patches with git am, resolve them manually and then run:

Terminal window
git am --resolved

To abort a git am operation and return to the previous state, use:

Terminal window
git am --abort

How do I continue a git am operation after resolving conflicts?

Section titled “How do I continue a git am operation after resolving conflicts?”

To continue a git am operation after resolving conflicts, execute:

Terminal window
git am --continue

How can I apply patches with signoff using git am?

Section titled “How can I apply patches with signoff using git am?”

To apply patches with a Signed-off-by line, use:

Terminal window
git am --signoff <patch-file>
  1. Applying a single patch file to the repository
  2. Applying patches from a mailbox archive with fallback to three-way merge
  3. Adding Signed-off-by lines when applying patches
  4. Skipping patches that fail to apply
  5. Applying patches interactively for user confirmation
  6. Stripping leading path components from patches
  7. Continuing patch application after resolving conflicts