如何使用 git filter-repo 修改某条commit 的作者信息
要使用 git filter-repo 修改某条 commit 的作者信息,请按以下步骤操作:
-
首先安装 git filter-repo 工具。你可以使用以下命令来安装:
pip3 install git-filter-repo -
切换到你的 Git 仓库目录。
-
运行以下命令来修改某条 commit 的作者信息:
git filter-repo --commit-callback ' if commit.committer.email == b"OLD_EMAIL@example.com": commit.committer_name = b"NEW_NAME" commit.committer_email = b"NEW_EMAIL@example.com" commit.author_name = b"NEW_NAME" commit.author_email = b"NEW_EMAIL@example.com" ' --force将
OLD_EMAIL@example.com替换为该 commit 原来的作者邮箱地址,将NEW_NAME和NEW_EMAIL@example.com替换为新的作者姓名和邮箱地址。 -
运行以下命令来强制推送修改后的 commit:
git push --force注意:强制推送会覆盖远程仓库的提交历史,请谨慎使用。
完成上述步骤后,你就可以成功修改某条 commit 的作者信息了。
原文地址: https://www.cveoy.top/t/topic/BzW 著作权归作者所有。请勿转载和采集!