git - 更改所有提交的 git 作者信息对我的一个存储库有效,但对其他存储库无效,为什么?

标签 git github sublimemerge

我有各种私有(private)GitHub repo 和使用Sublime Merge管理我的提交。

我要更改所有以前的提交作者详细信息 :

发件人姓名:这个,电子邮件:this@domain.com

收件人:姓名:那个,电子邮件:that@domain.com

因此我关注了these instructions来自 GitHub 并将代码修改为以下内容:

#!/bin/sh

git filter-branch -f --env-filter '

CORRECT_NAME="That"
CORRECT_EMAIL="that@domain.com"

export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"

' --tag-name-filter cat -- --branches --tags

在我使用 git push --force --tags origin 'refs/heads/*' 之前,在其中一个 repos 上有效来自指令的 Sublime Merge 显示了潜在的更改,并且在运行推送之后,所有提交现在都更新为所需的详细信息。

一切都很好,所以我想,直到我用我的其他几个存储库尝试了这个,并且在 sublime 中没有显示任何更改,并且推送什么也没做。我不知道为什么会有差异。其他存储库的相似之处在于它们都具有相同的原始提交者。

为什么这不适用于其他存储库,我该如何解决以允许我进行更改?

最佳答案

更好的选择是使用新工具 git filter-repo , 其中 replaces BFG and git filter-branch .
见其user manual .

To modify username and emails of commits, you can create a mailmap file in the format accepted by git-shortlog.
For example, if you have a file named my-mailmap you can run

git filter-repo --mailmap my-mailmap

and if the current contents of that file are as follows (if the specified mailmap file is version controlled, historical versions of the file are ignored):


Correct Name <correct@email.com> <old@email.com>

then we can update username and/or emails based on the specified mapping.



git shortlog "mapping author" section了解邮件映射文件的确切语法。

或者,使用 callbacks :
git-filter-repo --name-callback 'return name.replace(b"OldName", b"NewName")' \
   --email-callback 'return email.replace(b"old@email.com", b"new@email.com")'

关于git - 更改所有提交的 git 作者信息对我的一个存储库有效,但对其他存储库无效,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59590204/

相关文章:

git - 一个 git 命令显示目录中所有文件的状态

研究环境中的 git 工作流程

github - Github 和 Nuget 有什么区别?

sublimemerge - 崇高合并中的 Hunk 历史按钮是什么

git - 在 Sublime Merge 中显示分阶段更改

windows - 我是否需要同时为 Windows 10 和 WSL 安装 Git?

git - "git blame"文件访问控制修饰符

git - 解决方案具有位于解决方案文件夹之外的项目

git mv 不删除旧文件