Setting your commit email address

You can set the email address that is used to author commits on GitHub and on your computer.

About commit email addresses

GitHub uses your commit email address to associate commits with your GitHub account. You can choose the email address that will be associated with the commits you push from the command line as well as web-based Git operations you make.

For web-based Git operations, you can set your commit email address on GitHub. For commits you push from the command line, you can set your commit email address in Git.

Any commits you made prior to changing your commit email address are still associated with your previous email address.

Note: 您无法验证可用电子邮件地址服务中的电子邮件地址(允许您使用在一段时间后过期的临时地址接收电子邮件的服务)。 如果要对个人电子邮件地址保密,可以使用 GitHub 提供的 noreply 电子邮件地址。 更多信息请参阅“在 GitHub 上设置提交电子邮件地址”。

If you'd like to keep your personal email address private, you can use a GitHub-provided no-reply email address as your commit email address. To use your noreply email address for commits you push from the command line, use that email address when you set your commit email address in Git. To use your noreply address for web-based Git operations, set your commit email address on GitHub and choose to Keep my email address private.

You can also choose to block commits you push from the command line that expose your personal email address. For more information, see "Blocking command line pushes that expose your personal email."

To ensure that commits are attributed to you and appear in your contributions graph, use an email address that is connected to your GitHub account, or the noreply email address provided to you in your email settings. For more information, see "Adding an email address to your GitHub account."

Note: If you created your GitHub account after July 18, 2017, your GitHub-provided no-reply email address is a seven-digit ID number and your username in the form of ID+username@users.noreply.github.com. If you created your GitHub account prior to July 18, 2017, your GitHub-provided no-reply email address is your username in the form of username@users.noreply.github.com. You can get an ID-based GitHub-provided no-reply email address by selecting (or deselecting and reselecting) Keep my email address private in your email settings.

If you use your GitHub-provided noreply email address to make commits and then change your username, those commits will not be associated with your GitHub account. This does not apply if you're using the ID-based GitHub-provided noreply address. For more information, see "Changing your GitHub username."

Setting your commit email address on GitHub

如果您尚未启用电子邮件地址隐私保护,则在 GitHub 上编辑、删除或创建文件或者合并拉取请求时,可以选择将作者更改提交到哪个经验证的电子邮件地址。 如果您启用了电子邮件地址隐私,则不能更改提交作者电子邮件地址,默认情况下是 <username>@users.norreply.github.com

  1. 在任何页面的右上角,单击您的个人资料照片,然后单击 Settings(设置)用户栏中的 Settings 图标

  2. 在左侧边栏中,单击 Emails(电子邮件)电子邮件选项卡

  3. 在“Add email address(添加电子邮件地址)”中,输入您的电子邮件地址,然后单击 Add(添加)Email addition button

  4. 验证您的电子邮件地址

  5. 在“Primary email address(主要电子邮件地址)”列表中,选择要与基于 web 的 Git 操作关联的电子邮件地址。 主要电子邮件地址选择

  6. 要在执行基于 web 的 Git 操作时对您的电子邮件地址保密,请单击 Keep my email addresses private(对我的电子邮件地址保密)对电子邮件地址保密的复选框图像

Setting your commit email address in Git

You can use the git config command to change the email address you associate with your Git commits. The new email address you set will be visible in any future commits you push to GitHub from the command line. Any commits you made prior to changing your commit email address are still associated with your previous email address.

Setting your email address for every repository on your computer

  1. 打开 Terminal(终端)Terminal(终端)Git Bash
  2. 在 Git 中设置电子邮件地址。 您可以使用 GitHub 提供的 no-reply 电子邮件地址或任何电子邮件地址。
    $ git config --global user.email "email@example.com"
  3. 确认在 Git 中正确设置了电子邮件地址:
    $ git config --global user.email
    email@example.com
  4. 将电子邮件地址添加到您在 GitHub 上的帐户,以便您的提交归因于您并且出现在您的贡献图中。 更多信息请参阅“添加电子邮件地址到 GitHub 帐户”。

Setting your email address for a single repository

GitHub uses the email address set in your local Git configuration to associate commits pushed from the command line with your GitHub account.

You can change the email address associated with commits you make in a single repository. This will override your global Git config settings in this one repository, but will not affect any other repositories.

  1. 打开 Terminal(终端)Terminal(终端)Git Bash
  2. Change the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.
  3. 在 Git 中设置电子邮件地址。 您可以使用 GitHub 提供的 no-reply 电子邮件地址或任何电子邮件地址。
    $ git config user.email "email@example.com"
  4. 确认在 Git 中正确设置了电子邮件地址:
    $ git config user.email
    email@example.com
  5. 将电子邮件地址添加到您在 GitHub 上的帐户,以便您的提交归因于您并且出现在您的贡献图中。 更多信息请参阅“添加电子邮件地址到 GitHub 帐户”。

此文档对您有帮助吗?隐私政策

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。