我如何重写git仓库中的提交者名称? [英] How do I rewrite committer names in a git repository?

查看:98
本文介绍了我如何重写git仓库中的提交者名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I converted a Subversion repository to Git using git svn but unfortunately only now noticed that some of the author information was wrong. The converted repository is not shared with anybody yet, so I'd like to rewrite the commit logs in it - if possible.

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

How can I rewrite a git repository so that the log for all his commits show e.g.

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

而不是

instead of

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

我试图自己做这件事,而且似乎 git-filter-branch 是我所需要的。尽管我没有设法做到这一点。

I tried to do this myself, and it seems that git-filter-branch is what I need. I didn't manage to make it do this, though.

推荐答案

The ProGit book has a

The ProGit book has an example of doing this that should probably work for you.

$ 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

这篇关于我如何重写git仓库中的提交者名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆