git批量修改历史提交用户信息
https://www.cnblogs.com/daodaotest/p/13841951.html
#!/bin/sh
git filter-branch --env-filter '
# 之前的邮箱
OLD_EMAIL="aaa@aaa.com"
# 修改后的用户名
CORRECT_NAME="bbb"
# 修改后的邮箱
CORRECT_EMAIL="ccc@ccc.com"
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
如果有如下报错,说明原来执行过filter-branch,需要删除原来的备份,执行如下语句
git update-ref -d refs/original/refs/heads/master