批量修改git历史记录中的用户名和邮箱
大约 2 分钟
其实就一个脚本就搞定
#!/bin/sh
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
在仓库目录下执行上面的脚本,如果执行异常,尝试先执行下下面的命令再试:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD
如果提示下面的信息:
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
可以执行下面的命令:
git update-ref -d refs/original/refs/heads/分支名
然后push到远程,在远程仓库查看是否修改成功
git push --force --tags origin 'refs/heads/*'
系统推荐
- getPath vs getAbsolutePath vs getCanonicalPath
- 免费https证书、自动续期
- MySQL常用命令
- Spring Cloud(一):服务治理技术概览【Finchley 版】
- KVM方式集群部署ES
- 高可用通用方案
- Flutter开发需要涉及的知识点大纲
- 行转列不再复杂:SQL高手都在用的技巧揭秘
- Nginx的双向认证配置
- SpringBoot服务在服务启动完成前被提前注册到nacos
- Mermaid示例
- Linux
- 随机毒鸡汤:付出就会有回报,比如一倍的奢望,换两倍的失望。