Skip to main content
Chapter 49 of 61 · 3 sections · Page 164

Git: git send-email

Configure SMTP and send patch series to open source mailing lists using git send-email.

Original chapter reference: Chapter 49: git send-email. The command options and documentation recipes below are fully transcribed from Git Notes for Professionals.

Section 49.1: Use git send-email with Gmail

Background: if you work on a project like the Linux kernel, rather than make a pull request you will need to submit your commits to a listserv for review. This entry details how to use git-send email with Gmail.

Add the following to your .gitconfig file:

Source example · PDF page 164
[sendemail]
    smtpserver = smtp.googlemail.com
    smtpencryption = tls
    smtpserverport = 587
    smtpuser = name@gmail.com

Then on the web: Go to Google -> My Account -> Connected Apps & Sites -> Allow less secure apps -> Switch ON

To create a patch set:

Source example · PDF page 164
git format-patch HEAD~~~~ --subject-prefix="PATCH <project-name>"

Then send the patches to a listserv:

Source example · PDF page 164
git send-email --annotate --to project-developers-list@listserve.example.com 00*.patch

To create and send updated version (version 2 in this example) of the patch:

Source example · PDF page 164
git format-patch -v 2 HEAD~~~~  ......
git send-email --to project-developers-list@listserve.example.com v2-00*.patch

Section 49.2: Composing

Source example · PDF page 164
--from                    * Email From:
--[no-]to                 * Email To:
--[no-]cc                 * Email Cc:
--[no-]bcc                * Email Bcc:
--subject                 * Email "Subject:"
--in-reply-to             * Email "In-Reply-To:"
--[no-]xmailer                 * Add "X-Mailer:" header (default).
--[no-]annotate                * Review each patch that will be sent in an editor.
--compose                      * Open an editor for introduction.
--compose-encoding        * Encoding to assume for introduction.
--8bit-encoding           * Encoding to assume 8bit mails if undeclared
--transfer-encoding       * Transfer encoding to use (quoted-printable, 8bit, base64)

Section 49.3: Sending patches by mail

Suppose you’ve got a lot of commit against a project (here ulogd2, official branch is git-svn) and that you wan to send your patchset to the Mailling list devel@netfilter.org. To do so, just open a shell at the root of the git directory and use:

Source example · PDF page 164
git format-patch --stat -p --raw --signoff  --subject-prefix="ULOGD PATCH" -o /tmp/ulogd2/ -n git-
svn
git send-email --compose --no-chain-reply-to --to devel@netfilter.org /tmp/ulogd2/

First command will create a serie of mail from patches in /tmp/ulogd2/ with statistic report and second will start your editor to compose an introduction mail to the patchset. To avoid awful threaded mail series, one can use :

Source example · PDF page 165
git config sendemail.chainreplyto false

source

Buy me a coffee
Daily Practice
0/0