Git解决历史记录提交用户邮箱不匹配问题
posts/git%E8%A7%A3%E5%86%B3%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E6%8F%90%E4%BA%A4%E7%94%A8%E6%88%B7%E9%82%AE%E7%AE%B1%E4%B8%8D%E5%8C%B9%E9%85%8D%E9%97%AE%E9%A2%98问题来源
由于本地邮箱配置错误后导致多次提交关联了错误邮箱导致 Repo 上提交人无法关联 Github 账户
解决
OLD_EMAIL
为原来 Repo 中错误邮箱
CORRECT_NAME
为要更改的正确用户名
CORRECT_EMAIL
为要更改的正确邮箱
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Cyunrei"
CORRECT_EMAIL="[email protected]"
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