如何在git存储库中重写提交者名称?

时间:2009-10-14 14:51:11

标签: git

我使用git svn将Subversion存储库转换为Git,但遗憾的是现在只注意到一些作者信息是错误的。转换后的存储库尚未与任何人共享,因此我想重写其中的提交日志 - 如果可能的话。

如何重写git存储库,以便所有提交的日志显示如下。

Author: John Doe <john.doe@example.com>

而不是

Author: John Do <john.do@example.com>

我自己尝试这样做,似乎git-filter-branch就是我需要的。但是,我无法做到这一点。

1 个答案:

答案 0 :(得分:19)

The ProGit book an example of doing this可能适合您。

$ git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];
    then
            GIT_AUTHOR_NAME="Scott Chacon";
            GIT_AUTHOR_EMAIL="schacon@example.com";
            git commit-tree "$@";
    else
            git commit-tree "$@";
    fi' HEAD
相关问题