git 更改历史提交的邮箱信息

原文:

https://help.github.com/en/articles/changing-author-info

1.更改本地历史

git filter-branch -f --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.将更改历史push到服务器

git push --force --tags origin 'refs/heads/*'

你可能感兴趣的:(git)