Skip to main content

此版本的 GitHub Enterprise 将停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

Setting your commit email address

You can set the email address that is used to author commits on 您的 GitHub Enterprise Server 实例 and on your computer.

About commit email addresses

GitHub uses your commit email address to associate commits with your account on 您的 GitHub Enterprise Server 实例. 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 Enterprise Server 实例. 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 Enterprise Server 实例. For more information, see "Adding an email address to your GitHub account."

Setting your commit email address on GitHub

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

    用户栏中的 Settings 图标

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

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

  4. 在“Primary email address(主要电子邮件地址)”列表中,选择要与基于 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 Enterprise Server 实例 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 中设置电子邮件地址。 您可以使用 任何电子邮件地址。
    $ git config --global user.email "email@example.com"
  3. 确认在 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. 更多信息请参阅“添加电子邮件地址到 GitHub 帐户”。

Setting your email address for a single repository

GitHub Enterprise Server uses the email address set in your local Git configuration to associate commits pushed from the command line with your account on 您的 GitHub Enterprise Server 实例.

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. 打开 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 中设置电子邮件地址。 您可以使用 任何电子邮件地址。
    $ git config user.email "email@example.com"
  4. 确认在 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. 更多信息请参阅“添加电子邮件地址到 GitHub 帐户”。