[原创]How to send patch files by git send-mail

We can use the convenient git send-email command and specifying a file or a directory of files to send. For example, git send-email . will send all the files in the current directory.

Let’s assume that we have some patches files which are generated by git format-patch command in the current directory like this:

total 112
-rw-r--r-- 1 administrator staff 678B Sep 3 10:55 0001-Change-pink-to-a-manly-color.patch
-rw-r--r-- 1 administrator staff 815B Sep 3 10:55 0002-Add-a-pink-block-of-color.patch
drwxr-xr-x 5 administrator staff 160B Aug 31 07:50 about
-rw-r--r-- 1 administrator staff 315B Aug 31 07:48 blue.html
...

Git also requires some special configurations for this command:

  1. Edit ~/.gitconfig to specify your account settings:
[sendemail]
smtpEncryption = tls # tls is better than ssl
smtpServerPort = 587 # If you choose ssl, this should be 465
smtpServer = <smtp.gmail.com> # You can also use another email provider.
smtpUser = <your-username-to-send-email> # This must be identical to the <Form> email address in your patch files.
  1. From May 30, 2022, you must have multi-factor authentication set up on your Gmail account and generate an app-specific password for use with git send-email. Visit security.google.com/settings/secur... to create it.

  2. Once your commits are ready to be sent to the mailing list, run the following commands:

$ git send-email ./*.patch

The first time you run it, you will be prompted for your credentials. Enter the app-specific or your regular password as appropriate.

If you don’t want to type it the next time, you have to configure credential helper:

  1. Find a helper.

    $ git help -a | grep credential-
    credential-foo
  2. Read its description.

    $ git help credential-foo
  3. Tell Git to use it.

    $ git config credential.helper foo

References

  1. git-scm.com/docs/git-send-email
  2. git-scm.com/docs/gitcredentials
  3. git-scm.com/docs/git-credential-st...
本作品采用《CC 协议》,转载必须注明作者和本文链接
日拱一卒
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
93
粉丝
85
喜欢
153
收藏
121
排名:71
访问:11.4 万
私信
所有博文
社区赞助商