序号 | 录入时间 | 录入人 | 备注 |
---|---|---|---|
1 | 2017-08-29 | Alfred Jiang | - |
Git - 通过 Shell 脚本批量修改历史递交记录中的用户名和邮箱
Git \ Shell 脚本 \ 批量修改历史递交记录
1. 在仓库根目录(.git 文件所在目录)编写以下脚本并执行,替换 [email protected]
、Your Correct Name
和 [email protected]
为你需要修改的
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
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
git push --force --tags origin 'refs/heads/*'
(无)
(无)