如何从历史的GitHub提交记录中移除或更改您的Git用户名?

3

我担心我的隐私,不希望在github提交记录中出现我的真名。我刚刚发现,github保存了我的user.name和github用户名作为贡献者。我已经更改了本地git的user.name,以便未来的提交记录不会有问题。但是我现在想知道如何回去更改之前在github仓库中提交的user.name?

1个回答

0
除了评论中建议的filter-branch之外,交互式变基是另一个选项。
使用交互式变基。
git rebase -i -p <some HEAD before all of your bad commits>

然后在rebase文件中将所有错误的提交标记为“edit”。接下来,当git要求您修改每个提交时,请执行以下操作

 git commit --amend --author "New Author Name <email@address.com>" 

保存并关闭打开的编辑器,然后执行

git rebase --continue

继续变基操作。

添加--no-edit以跳过打开编辑器,使命令变为:

git commit --amend --author "New Author Name <email@address.com>" --no-edit && \
git rebase --continue

更改作者和提交者:

 git -c user.name="New Author Name" -c user.email=email@address.com commit --amend --reset-author

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接