This is a simple and correct guide for setting up git send-email and sending patches over email.
- It's fast, lightweight, and works everywhere.
- It leaves a good record (every patch = an email = permanent).
- Some projects prefer email over pull requests.
gitgit send-email- An SMTP server (your email provider) to send emails
| Distro | Install Command |
|---|---|
| Ubuntu/Debian | sudo apt install git-email |
| Fedora | sudo dnf install git-email |
| Arch Linux | Already included with git |
Set your username and email:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"Configure SMTP settings so Git can send the patches.
git config --global sendemail.smtpServer smtp.yourprovider.com
git config --global sendemail.smtpUser [email protected]
git config --global sendemail.smtpServerPort 587
git config --global sendemail.smtpEncryption tlsNotes:
- Gmail SMTP:
smtp.gmail.com - Outlook SMTP:
smtp.office365.com - ProtonMail (Bridge):
127.0.0.1
If you skip smtpPass, Git will ask for your password when sending.
After committing changes, create a patch file:
git format-patch -1 HEADThis generates a patch file like 0001-some-change.patch.
If you have multiple commits you want to send:
git format-patch -N HEADwhere N is the number of commits you want.
Example: to create patches for the last 3 commits:
git format-patch -3 HEADIf you need to send patches to the right people, you can use a script (if available in the project) like:
./scripts/get_maintainer.pl 0001-some-change.patch(This is optional; depends on the project.)
Send the patch using email:
git send-email --to [email protected] 0001-some-change.patchIf you're sending multiple patches, you can send them all at once:
git send-email --to [email protected] 000*.patchYou can CC others using --cc.
If you're sending multiple patches, it's good practice to send a short "cover letter" email explaining what the patch series does.
Create the patches with:
git format-patch -N --cover-letter HEADThis will create a 0000-cover-letter.patch you can edit before sending.
Then send all patches including the cover letter:
git send-email --to [email protected] 000*.patchAlways dry-run first to check if everything works:
git send-email --dry-run --to [email protected] 0001-some-change.patchIf you don't want to store your SMTP password:
git config --global sendemail.smtppass dummyGit will then ask for your password each time you send.
- Always set a good subject line for your patches (explain the change briefly).
- Write a good commit message (title + body).
- CC relevant maintainers or mailing lists if needed.
- Reply to feedback and be polite.
- If you resend patches (v2, v3, etc.), mention version in the subject line.
Example subject for v2:
If you get feedback and need to send a corrected patch:
- Make the fixes.
- Create a new patch (using
git format-patch). - Add version info manually in subject line or with options like:
git format-patch -v2 -1 HEAD- Send again using
git send-email.
Important: When sending v2, v3, etc., reply in the same email thread if possible. Use --in-reply-to option with the Message-ID of the previous email.
Example:
git send-email --in-reply-to="[email protected]" 0001-new-fix.patch[git config user.email] --> sets your From: address
[git config sendemail.smtpServer] --> sets SMTP settings
[git format-patch] --> creates patch files
[git send-email] --> sends patch files over SMTP
If I have missed something or included any wrong info, you are welcome to correct me. Thank you!