1、执行一个 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
2、如果遇到权限问题则赋予权限,例如
Permission denied
#执行如下命令
chmod +x XXXX.sh
3、如果遇到以下错误,修复它
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
#执行如下命令
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD
4、最后提交(慎重)
git push origin --force --all
快来评论一下吧!
发表评论