参考解决方案:
https://help.github.com/en/articles/changing-author-info
https://blog.csdn.net/ouyang_peng/article/details/75329779
1.保证自己本地仓库和远程仓库同步
2.在本地项目下写一个脚本renamesh.sh
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
注意:OLD_EMAIL、CORRECT_NAME、CORRECT_EMAIL 需要修改
3.运行脚本
chmod +x renamesh.sh
./renamesh.sh
4.推送正确历史记录到github
git push --force --tags origin 'refs/heads/*'
说明:建议按照github的步骤进行,clone个库下来