Prepare Email Patches With git format-patch

Export commits as mbox files suitable for mailing lists.

macOSautomationgitcliLow risk
Run git format-patch -1 HEAD -o patches/ to write the last commit as a .patch file.

01Command

Command
$ git format-patch -1 HEAD -o patches/

02What it does

format-patch captures a commit as an email-compatible patch with the message, author and diff, which projects like the Linux kernel review through mailing lists. It shows how Git's workflow extends beyond web pull requests.

03Risk

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!Warning: Patches embed author email addresses; confirm the identity and recipients before sending.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer