Last Updated: February 16, 2020
·
9.766K
· unsignedzero

Setting up and using git send-email with gmail.

I've tried using git send-email and it seems that it doesn't come with batteries. Anyway here's a quick guide to setting it up.

Back end:

Following this stackoverflow post, git-email needs to be installed on the system.

apt-get install git-email

Afterwards, the Perl scripts git-email calls needs to be set up from Git-Scm. Assuming perl is installed,

cpan Authen::SASL MIME::Base64 Net::SMTP::SSL

I ran each module install individually but this should work as well. Once this is done, the back end is setup. Let's move on to the front end.

Front end:

From another codewall post, (Setting up git send-email with gmail)[https://coderwall.com/p/dp-gka "Setting up git send-email with gmail"], this should be added into your ~/.gitconfig.

[sendemail]
from = YourName <email@gmail.com>

chainreplyto = false

smtpencryption = tls
smtppass = PASSWORD
smtpserver = smtp.gmail.com
smtpserverport = 587
smtpuser = email@gmail.com

The smtppass is optional and the system will prompt you, if you don't want it written in plaintext.

For those who want to add a body or change the last commit message itself, use

git commit --amend

If any text is changed in the commit message, this will generate a different commit.
This will load your default editor and allow you to edit what you want. The first line is your subject line. If you want a body, hit enter twice and start typing. The empty line signifies its a body.

Don't forget to sign off once you're done or use

git commit --amend -s

To construct the patch you may use,

git format-patch --cover-letter -M origin/master -o outgoing/

However, if you only have one file, you might not want a cover letter. In that case
use

git format-patch -1

-1 specifies how many commits we are going back to create as patches, in this case 1.

Once that's done, you should get a file 0001.<part of commit message>.patch.

To send it, use

git send-email <files>

If you're sending a new patch, hit enter when prompted by

Message-ID to be used as In-Reply-To for the first email?

By default git send-email will CC the author of the patch as well.

If there are still more problems, view (Troubleshooting "git send-email" problems)[https://wincent.com/wiki/Troubleshooting_%22git_send-email%22_problems] and add those perl modules.