先执行修改,替换成新的 用户名和 邮箱,注意 (以下方式会将所有人的提交都转换成新的记录)
git filter-branch -f --env-filter \
"GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='newemail'; \
GIT_COMMITTER_NAME='committed-name'; GIT_COMMITTER_EMAIL='committed-email';" HEAD
然后将更改的历史记录推送到原始存储库中,请使用:
git push origin +yourbranch
加号 也需要输入,然后即可
下面这种 可以实现替换
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "wrong_email@wrong_host.local" ];
then
GIT_AUTHOR_NAME="Your Name Here (In Lights)";
GIT_AUTHOR_EMAIL="correct_email@correct_host.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD