我有两个账号在仓库里进行提交。一个是临时的,一个是正式的。
目标
我要把临时的提交作者test cool_tester@mail.com 替换成正式的 handsome handsome_boy@mail.com
操作
- 前置条件
- python
- 安装
python -m pip install git-filter-repo
- 在 git 工程目录下,新建文件
authors.txt里面的内容如下
handsome <handsome_boy@mail.com> <cool_tester@mail.com>
- 执行替换
git filter-repo --force --mailmap authors.txt
从执行后的输出可知,它把remote给删了,这是为了安全,以防你把错误的修改提交上去。
- 把repo地址添加回来
git remote add origin ssh://git@myrepo.git
- 看看提交作者记录(可选)
git shortlog -sne
如果有问题,作者信息有误就不要提交了,可以删掉本地仓库重新操作。
- 推送修改
git push --force --all
git push --force --tags