注意:这个问题有点模糊,我认为OP在凭据与作者方面存在问题。这是对问题的回答:
“我更改了 github 凭据,为什么我的贡献仍然链接到我的旧帐户?”
“凭证”有两个完全独立的概念:
- 一是您用于交互的凭据与 github:它由用于通过 ssh 连接的 ssh 密钥或用于通过 https 连接的登录名:密码(或变体...)表示
- 另一个是您提交中出现的姓名和电子邮件in git——你跑步时看到的那个
git log
例如在你的终端中——你通常使用git config user.name
and git config user.email
您需要 1. 为了在 github 上执行一些操作:推送到存储库、从私有存储库读取等...
但是 1. 不会影响或修改 2. :您完全可以推送由 Alice 编写的提交,而 Alice 也可以完全推送由您编写的提交。
因此,即使您更改了 github 的凭据(即 1.),您的存储库历史记录仍然提到相同的作者和提交者(即 2.)。 github 扫描的信息是 2. 存储在存储库历史记录中的电子邮件。
- 如果您的目的是保留当前历史记录,并使用“新”电子邮件地址进行新提交:只需设置两个 git config 参数
git config user.name "updated name"
git config user.email "[email protected] /cdn-cgi/l/email-protection"
# if you want to apply this to all projects on your computer
# (at least: all the ones that do not have a local user.email config)
git config --global user.name "updated name"
git config --global user.email "[email protected] /cdn-cgi/l/email-protection"
# to check, within a repository, what email is used:
git config user.email
git config --show-origin user.email
- 如果您想在 github 上将上一封电子邮件的所有贡献链接到您的新帐户:
在 github GUI 中,转到您的个人资料部分并添加其他电子邮件。
如果相关的话,您可能还需要删除您以前的帐户。
- 如果您无法(或不想)将两个电子邮件地址链接到您的新 github 帐户,您可以重写存储库的历史记录以更改作者姓名
quoting 接受的答案 https://stackoverflow.com/a/750182/86072对这个问题“如何更改多次提交的作者和提交者姓名/电子邮件?” https://stackoverflow.com/questions/750172:
using git 过滤器仓库 https://github.com/newren/git-filter-repo/,你可以先安装它并构建一个git-mailmap
根据格式gitmailmap https://htmlpreview.github.io/?https://raw.githubusercontent.com/newren/git-filter-repo/docs/html/gitmailmap.html.
Proper Name <[email protected] /cdn-cgi/l/email-protection> Commit Name <[email protected] /cdn-cgi/l/email-protection>
然后使用创建的邮件映射运行filter-repo:
git filter-repo --mailmap git-mailmap
(note:答案最初提供了一个可行的解决方案git filter-branch
,然后添加更新git filter-repo
工具可用。我只是强调答案的这一部分,因为恕我直言,迄今为止,这是最合适的方法)