gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 00:59:44 26 4
gpt4 key购买 nike

我有各种私有(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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com