git-am - Linux


git-am is a Git utility used to apply a series of patches from a patch file to the current working tree. It is particularly useful for applying multiple patches in a controlled and orderly manner.


git am [<options>] <patch file>


  • -3 (-threeway): Use three-way merge instead of the default two-way merge.
  • -s (–signoff): Add a Signed-off-by line to each commit message.
  • -m (-message): Specify a custom commit message.
  • -C (-committer): Specify the name and email of the committer.
  • –continue (-c): Continue applying patches even if a conflict occurs.
  • –abort (-a): Abort the patch application process if a conflict occurs.
  • -u (–update): Update the index after each successful patch application.


Example 1: Apply a single patch file:

git am my-patch.patch

Example 2: Apply a series of patches with a three-way merge:

git am -3 my-patch-series.patch

Example 3: Apply a patch file with a custom commit message:

git am -m "Fix: Resolve merge conflict" my-patch.patch

Common Issues

  • Merge conflicts: Conflicts can occur if the patches being applied modify the same lines of code. Use the -3 option to resolve these conflicts using a three-way merge.
  • Invalid patch format: Ensure that the patch file is in a valid format. Use the git diff -p command to verify the patch before applying it.


  • git commit -a: Commit all changes made by git-am.
  • grep -P: Search for specific patterns within patch files.
  • sed: Modify patch files before applying them.

Related Commands

  • git format-patch: Create a patch file from a specified range of commits.
  • git cherry-pick: Apply a single commit from a different branch.
  • git merge: Merge changes from another branch.