LinuxCommandLibrary

git-send-email

Send Git patches as emails

TLDR

Send the last commit in the current branch interactively

$ git send-email -1
copy

Send a given commit
$ git send-email -1 [commit]
copy

Send multiple (e.g. 10) commits in the current branch
$ git send-email [-10]
copy

Send an introductory email message for the patch series
$ git send-email -[number_of_commits] --compose
copy

Review and edit the email message for each patch you're about to send
$ git send-email -[number_of_commits] --annotate
copy

SYNOPSIS

git send-email [options] <file | directory | rev-list options>...

PARAMETERS

--to <address> [--to=<address> ...]
    Primary recipient(s) for To: header.

--cc <address> [--cc=<address> ...]
    Carbon copy recipient(s).

--bcc <address> [--bcc=<address> ...]
    Blind carbon copy recipient(s).

--from <address>
    Sender address (overrides config).

--sender <address>
    Sender identity for non-author emails.

--in-reply-to <identifier>
    Message-ID for threading.

--subject <string>
    Override default subject.

--smtp-server <host>[:<port>]
    SMTP server (default: localhost).

--smtp-encryption={smtp,ssl,tls}
    Encryption method for SMTP.

--smtp-user <user>
    SMTP username.

--smtp-pass <password>
    SMTP password (insecure).

--dry-run
    Simulate sending without transmitting.

--validate [={basic|always}]
    Validate email addresses.

--suppress-from
    Omit From: if sender matches author.

--no-thread
    Disable threading.

--no-chain-reply-to
    Disable chainreply behavior.

--8bit-encoding <encoding>
    Encoding for 8bit cleanup.

--transfer-encoding {auto|7bit|8bit-quoted-printable|quoted-printable|base64}
    MIME transfer encoding.

--annotate
    Edit each patch before sending.

--confirm [={always|cc|compose|auto}]
    Confirmation prompts before sending.

--quiet
    Suppress all output.

--format-patch
    Generate patches internally if no files given.

DESCRIPTION

git send-email is a Git command-line tool for formatting and sending collections of patches as emails, primarily to mailing lists or maintainers. It works seamlessly with git format-patch, which generates patch files from commit ranges, converting them into properly formatted MIME emails with attachments.

Key capabilities include specifying recipients via --to, --cc, and --bcc; threading emails with --in-reply-to; customizing subjects; and supporting various SMTP configurations for secure transmission (e.g., TLS/SSL). It validates email addresses, performs dry runs for testing, and suppresses redundant headers like From: when unnecessary.

Configuration is drawn from .gitconfig (section sendemail), allowing defaults for servers, authentication, and aliases. It's the standard for workflows in projects like the Linux kernel, ensuring patches are reviewable and traceable. Users can send from directories of patches, stdin, or directly from revisions.

The tool emphasizes reliability, with options for 8bit quoting, transfer encoding, and identity management, making it robust for large patch series.

CAVEATS

Requires SMTP access or sendmail; insecure password prompts unless configured; does not handle HTML bodies; network-dependent; respects sendemail config but overrides via CLI.

CONFIGURATION

Key git config options: sendemail.smtpServer, sendemail.smtpEncryption=tls, sendemail.smtpUser, sendemail.aliasFile for recipient aliases.

COMMON USAGE

git format-patch -3 --stdout | git send-email --to=dev@example.com --cc=reviewer@example.com
git send-email --dry-run *.patch

HISTORY

Introduced in Git 1.3.0 (2006) by Linus Torvalds and contributors for kernel patch submission. Evolved with SMTP support, TLS encryption (Git 1.7+), and threading improvements; integral to Git's porcelain commands.

SEE ALSO

Copied to clipboard