我想在所有提交中更改我的姓名和电子邮件地址,可以吗?
发布于 2010-12-21 05:16:53
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Josh Lee" ];
then export GIT_AUTHOR_NAME="Hobo Bob"; export GIT_AUTHOR_EMAIL=hobo@example.com;
fi; git commit-tree "$@"'
这只影响作者,而不影响提交者(对于大多数提交来说,提交者与作者相同)。如果还想重写这两个变量,请设置GIT_COMMITTER_NAME
和GIT_COMMITTER_EMAIL
变量。
关于重写历史的standard warning适用;只对尚未共享的历史进行重写。
2018年6月更新
现在,该手册的示例中包含了一个使用--env-filter
的解决方案:https://git-scm.com/docs/git-filter-branch#_examples:
git filter-branch --env-filter '
if test "$GIT_AUTHOR_EMAIL" = "root@localhost"
then
GIT_AUTHOR_EMAIL=john@example.com
fi
if test "$GIT_COMMITTER_EMAIL" = "root@localhost"
then
GIT_COMMITTER_EMAIL=john@example.com
fi
' -- --all
发布于 2014-05-09 20:33:31
要在所有选定的提交中同时重写作者和提交者:
git filter-branch --commit-filter \
'if [ "$GIT_AUTHOR_NAME" = "OldAuthor Name" ]; then \
export GIT_AUTHOR_NAME="Author Name";\
export GIT_AUTHOR_EMAIL=authorEmail@example.com;\
export GIT_COMMITTER_NAME="Commmiter Name";\
export GIT_COMMITTER_EMAIL=commiterEmail@example.com;\
fi;\
git commit-tree "$@"'
发布于 2012-06-27 15:15:42
如果没有其他作者,您可以这样做:
git filter-branch --commit-filter 'export GIT_AUTHOR_NAME="authorname"; \
export GIT_AUTHOR_EMAIL=mail@example.com; git commit-tree "$@"'
https://stackoverflow.com/questions/4493936
复制相似问题