Git Patch and Email Workflows

Patch-oriented Git workflows using format-patch, apply, am, and range-diff for mailing-list and review-based collaboration.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Create Patch Series
Format last commit
git format-patch -1 HEAD

# Generate one patch file from latest commit.

Format commit range
git format-patch origin/main..HEAD

# Generate patches for commits not yet upstream.

Format with cover letter
git format-patch --cover-letter -3

# Generate last 3 commits plus cover letter template.

Format threaded series
git format-patch --thread -5

# Prepare patches for email threading.

## Apply Patches and Mailboxes
Check patch applicability
git apply --check feature.patch

# Validate patch without modifying files.

Apply patch and update index
git apply --index feature.patch

# Apply patch to working tree and index.

Apply mailbox series
git am 0001-feature.patch

# Apply email-formatted patches as commits.

Continue git am
git am --continue

# Resume after conflict resolution.

Abort git am
git am --abort

# Cancel mailbox application and restore state.

## Review and Compare Series
Range-diff two series
git range-diff origin/main...v1 origin/main...v2

# Review changes between patch series revisions.

Log with patches
git log -p origin/main..HEAD

# Review commits as patch text.

Show one commit patch
git show --patch <commit_sha>

# Inspect a single commit as patch text.