Skip to main content

Setting your commit email address

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

Platform navigation

About commit email addresses

GitHub uses your commit email address to associate commits with your account on GitHub. 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.

注意

您无法验证可用电子邮件地址服务中的电子邮件地址(允许您使用在一段时间后过期的临时地址接收电子邮件的服务)。 如果要将个人电子邮件地址保密,可以使用 GitHub 提供的 noreply 电子邮件地址。 有关详细信息,请参阅“Setting 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 address.

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

注意

If you created your account after July 18, 2017, your noreply email address is an ID number and your username in the form of ID+USERNAME@users.noreply.github.com. If you created your account prior to July 18, 2017, and enabled Keep my email address private prior to that date, your noreply email address is USERNAME@users.noreply.github.com. You can get an ID-based noreply email address by selecting (or deselecting and reselecting) Keep my email address private in your email settings.

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

Setting your commit email address on GitHub

如果尚未启用电子邮件地址隐私保护,则在用户界面中编辑、删除或创建文件或者合并拉取请求时,可以选择将作者更改提交到哪个经验证的电子邮件地址。 如果启用了电子邮件地址隐私,则不能更改提交作者电子邮件地址,并且默认情况下是无回复电子邮件地址。 有关无回复电子邮件地址可以采用的确切格式的详细信息,请参阅 Setting your commit email address

  1. 在 GitHub 任意页面的右上角,单击个人资料照片,然后单击 “设置”****。

  2. 在侧边栏的“访问”部分,单击“ 电子邮件”。

  3. 在“添加电子邮件地址”中,键入你的电子邮件地址并单击“添加”。

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

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

    “电子邮件”设置页的屏幕截图。 在“主要电子邮件地址”下,标有 Octocat 电子邮件地址的下拉菜单用橙色框出。

  6. 要在执行基于 Web 的 Git 操作时对电子邮件地址保密,请选择“对我的电子邮件地址保密”****。

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. 打开终端终端Git Bash

  2. 在 Git 中设置电子邮件地址。 可以使用 GitHub 提供的 noreply 电子邮件地址或任何电子邮件地址。

    git config --global user.email "YOUR_EMAIL"
    
  3. 确认在 Git 中正确设置了电子邮件地址:

    $ git config --global user.email
    email@example.com
    
  4. 将电子邮件地址添加到 GitHub 上的帐户,以便提交归属于你并显示在你的贡献图中。 有关详细信息,请参阅“Adding an email address to your GitHub account”。

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 account on GitHub.

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

  1. 打开终端终端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 提供的 noreply 电子邮件地址或任何电子邮件地址。

    git config user.email "YOUR_EMAIL"
    
  4. 确认在 Git 中正确设置了电子邮件地址:

    $ git config user.email
    email@example.com
    
  5. 将电子邮件地址添加到 GitHub 上的帐户,以便提交归属于你并显示在你的贡献图中。 有关详细信息,请参阅“Adding an email address to your GitHub account”。