您可以将git filter-branch
其用于您的目的;具体来说,它的env-filter
.
--env-filter <command>
This filter may be used if you only need to modify the environment in which
the commit will be performed. Specifically, you might want to rewrite
the author/committer name/email/time environment variables (see
git-commit-tree(1) for details). Do not forget to re-export the variables.
就像是:
git filter-branch \
--env-filter 'export GIT_AUTHOR_NAME="First Last";
export GIT_AUTHOR_EMAIL="otheremail@email.com";
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}";
export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}";' \
-- --all
如果您不需要更改作者姓名,只需删除GIT_AUTHOR_NAME
和GIT_COMMITTER_NAME
分配。