Home·Terminal commands

git am

git

Usage

git am [-3] <mbox|patch>...

Turns mailed patches into commits, keeping the original author and message; on failure it stops in the middle of the series, so you have to finish with --continue, --skip or --abort.

Common flags

FlagMeaning
-3three-way merge when the patch does not apply cleanly
-sadd a Signed-off-by line
--continuego on after you fixed the conflict
--skipdrop this patch and continue the series
--abortundo the whole series
-kkeep the subject line exactly as it is

Examples

git am 0001-fix-login.patch

commits the patch, keeping its original author

git am -3 *.patch

applies a whole series, merging where needed

git am --abort

returns to before the series started

The confusion is that undo has several shapes — moving where a branch points is not the same as adding a commit that reverses it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does git am do?

Turns mailed patches into commits, keeping the original author and message; on failure it stops in the middle of the series, so you have to finish with --continue, --skip or --abort.

Q. How do I type it?

git am [-3] <mbox|patch>... — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

6 are listed here; the full set is in man git. This command sits under git.

Related commands

man page: man git-am