Skip to main content

此版本的 GitHub Enterprise Server 将于以下日期停止服务 2026-03-17. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

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

Setting your commit email address on GitHub

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

  2. 在边栏的“Access”部分中,单击 “Emails”****。

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

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

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

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 中设置电子邮件地址。 可以使用任何电子邮件地址。

    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 中设置电子邮件地址。 可以使用任何电子邮件地址。

    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”。

Next steps

For reference information, see 电子邮件地址参考.

To learn more about using a private email address, see 电子邮件地址参考.