- 在git项目目录下创建一个脚本文件email.sh,内容如下
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="原邮箱地址"
CORRECT_NAME="新用户名"
CORRECT_EMAIL="新邮箱地址"
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
- 执行email.sh,windows环境可通过git-bash.exe执行脚本
./email.sh
git log
git push origin --force --all
网友评论