Git · Patches and plumbing

git format-patch

Exports commits as email-ready patch files.

Syntax
git format-patch <range>

Example

Example
git format-patch origin/main --stdout > changes.patch

More in this group

git am git apply git apply --check git bundle git bundle verify git commit-tree git read-tree git replace

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course