Skip to content
LatchkeyLatchkey home

git format-patch --cover-letter: Usage, Options & Common CI Errors

git format-patch --cover-letter prepends a 0000 summary patch that introduces the whole series.

When sending more than one patch, a cover letter (0000-cover-letter.patch) gives reviewers the high-level story before the individual commits. It is the standard for multi-patch submissions.

What it does

git format-patch --cover-letter generates the usual numbered patch files plus an extra 0000 cover letter containing the series shortlog and diffstat, ready for editing and sending.

Common usage

Terminal
git format-patch --cover-letter -3 -o out/
git format-patch --cover-letter origin/main
git format-patch --cover-letter --subject-prefix="PATCH v2" main..feature
# then edit out/0000-cover-letter.patch before sending

Options

FlagWhat it does
--cover-letterEmit a 0000 summary patch
-o <dir>Write patches to a directory
--subject-prefix=<text>Override the [PATCH] prefix
-v <n> / --reroll-countMark the series as version n
--threadAdd threading headers

Common errors in CI

A frequent slip is sending the cover letter with its placeholder subject still set to "* SUBJECT HERE *" - edit it before send-email. An empty or reversed range (e.g. feature..main) produces no patches; verify the range yields commits with git rev-list --count first.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git format-patch --cover-letter: Usage, Options & Common CI Errors?
When sending more than one patch, a cover letter (0000-cover-letter.patch) gives reviewers the high-level story before the individual commits. It is the standard for multi-patch submissions.
What it does?
git format-patch --cover-letter generates the usual numbered patch files plus an extra 0000 cover letter containing the series shortlog and diffstat, ready for editing and sending.
Common errors in CI?
A frequent slip is sending the cover letter with its placeholder subject still set to "* SUBJECT HERE *" - edit it before send-email. An empty or reversed range (e.g. feature..main) produces no patches; verify the range yields commits with git rev-list --count first.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card