用 Github 官方脚本(git filter-branch方案)
- filter-branch 脚本
git filter-branch --env-filter '
export GIT_AUTHOR_NAME="yinzhidong"
export GIT_AUTHOR_EMAIL="yinzhidong@users.noreply.github.com"
export GIT_COMMITTER_NAME="yinzhidong"
export GIT_COMMITTER_EMAIL="yinzhidong@users.noreply.github.com"
' -- --branches --tags
注意: GIT_AUTHOR_NAME、 GIT_AUTHOR_EMAIL 修改为你的
- 校验是否修改成功
git log --pretty=format:"%an <%ae> | %cn <%ce>"
- 临时关闭 github 邮箱保护(不推荐,会暴露真实邮箱)
- 打开页面:https://github.com/settings/emails
- 取消勾选:Block command line pushes that expose my email
- 强制推送
git push --force origin main