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
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 sendingOptions
| Flag | What it does |
|---|---|
| --cover-letter | Emit a 0000 summary patch |
| -o <dir> | Write patches to a directory |
| --subject-prefix=<text> | Override the [PATCH] prefix |
| -v <n> / --reroll-count | Mark the series as version n |
| --thread | Add 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.
- 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