using git send-mail with google 2-factor authentication
You can use the normal Git config to store the password, like so:
git config --global sendemail.smtpencryption tls
git config --global sendemail.smtpserver mail.example.com
git config --global sendemail.smtpuser [email protected]
git config --global sendemail.smtpserverport 587
git config --global sendemail.smtppass smbumqjiurmqrywm
That will, of course, store the password in plain text. You should make sure your ~/.gitconfig file is not readable by others.
You could also store the password in an encrypted file and use that. You'd still have to remember and enter the password for the encryption, but at least you'd be able to choose that password. Something like gpg2
should do the trick.
Of course, in the end, the only really secure place to store the password is between your ears.
Source
Turns out git has a credential store. Linux, OS X, and Windows all have credential helpers that can collect credentials from the OS's keyring. This answer has a few examples.
If you'd rather have the patch saved to your drafts folder so you can review it before sending (or just so that Gmail tracks the thread better), you can do the following:
git config --global imap.host imaps://imap.gmail.com
git config --global imap.user [email protected]
git config --global imap.port 993
git config --global imap.sslverify false
git config --global imap.folder [Gmail]/Drafts
git format-patch --stdout | git imap-send
git-credential
support for git-imap-send
has been available since git 2.1.0.