git - 更改 GitHub 用户名时提交归属?

标签 git github

我愿意更新我的 GitHub 用户名,以便与其他网站和社交媒体更加一致和可识别。

根据GitHub docs

Git commits that were associated with your GitHub-provided noreply email address won't be attributed to your new username and won't appear in your contributions graph. If your Git commits are associated with another email address you've added to your GitHub account, including the ID-based GitHub-provided noreply email address, they'll continue to be attributed to you and appear in your contributions graph after you've changed your username. For more information on setting your email address, see "Setting your commit email address."

具体是什么意思?如果我理解正确,如果我更改我的用户名,我的提交将不再归于我吗? “noreply 电子邮件地址”和“基于 ID 的 noreply 电子邮件地址”的正确含义是什么? 如何确定我的提交是否与一个或另一个相关联?

换句话说,如何在更改用户名之前检查我是否会丢失提交属性?

请注意,我在本地工作,git config --list | grep email给我user.email=<my-real-email>@gmail.com .

最佳答案

另一个答案主要回答了这个问题,但还有一个额外的考虑因素。您可以将您的提交归因于您的新用户名即使您一直使用 GitHub 的无回复电子邮件地址,具体取决于地址的外观。文档中的关键段落如下:

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."

较旧的无回复地址是基于用户名的,因此与您的 GitHub 用户名相关联。如果您的提交使用了这样的地址,那么它们将继续归属于旧用户名,并且不会切换到您的新用户名。如果后来有人使用旧用户名,这些提交将归于该用户。

自 2017 年 7 月 18 日起,GitHub 通过向无回复地址添加 ID 更改了此功能。此 ID 现在与您的帐户相关联,并且与您的用户名无关。如果您有一个基于 ID 的地址,更改用户名仍然会将来自该地址的所有提交归于您。但是,如果您在基于 ID 的地址发布之前开始使用 GitHub 的无回复电子邮件功能,您将继续使用旧形式的地址,除非您明确重新选择该选项,如注释所述。

总而言之,提交将在用户名更改后继续归因于您的帐户,如果:

  1. 提交使用了与您的 GitHub 帐户关联的电子邮件地址
  2. 提交使用了 GitHub 提供的基于 ID 的无回复电子邮件地址

关于git - 更改 GitHub 用户名时提交归属?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63690503/

相关文章:

Github:将上游分支导入fork

git - 如何在git中维护生产和开发分支?

Git 不会在后续克隆上克隆所有分支?

git - 如何设置中间 git 服务器?这是否可取?

git - 对 latex 文件使用 git 的 word-diff

javascript - 导入直接从github安装的npm模块

xcode - 如何将 Xcode 与 GitHub 集成?

unix - ssh命令-T选项

java - 是否可以仅从一个特定分支触发 Jenkins?

git - 你能对特定的 git 分支进行 diff 分析吗?