Skip to main content

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

设置提交电子邮件地址

可以设置用于在 GitHub 和计算机上创作提交的电子邮件地址。

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.

After changing your commit email address on GitHub Enterprise Server, the new email address will be visible in all of your future web-based Git operations by default. Any commits you made prior to changing your commit email address are still associated with your previous 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. For more information, see "Adding an email address to your GitHub account."

Setting your commit email address on GitHub

  1. In the upper-right corner of any page on GitHub, click your profile photo, then click Settings.

  2. In the "Access" section of the sidebar, click Emails.

  3. In "Add email address", type your email address and click Add.

  4. In the "Primary email address" dropdown menu, select the email address you'd like to associate with your web-based Git operations.

    Screenshot of the "Email" settings page. Under "Primary email address," a dropdown menu, labeled with Octocat's email address, is outlined in orange.

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. Open TerminalTerminalGit Bash.

  2. Set an email address in Git. You can use any email address.

    git config --global user.email "YOUR_EMAIL"
    
  3. Confirm that you have set the email address correctly in Git:

    $ git config --global user.email
    email@example.com
    
  4. Add the email address to your account on GitHub Enterprise Server, so that your commits are attributed to you and appear in your contributions graph. For more information, see "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. Open TerminalTerminalGit 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. Set an email address in Git. You can use any email address.

    git config user.email "YOUR_EMAIL"
    
  4. Confirm that you have set the email address correctly in Git:

    $ git config user.email
    email@example.com
    
  5. Add the email address to your account on GitHub Enterprise Server, so that your commits are attributed to you and appear in your contributions graph. For more information, see "Adding an email address to your GitHub account."