我已经在git仓库上工作了一段时间,并做了一些提交.我一直在php文件中使用文档块,包括我的私人电子邮件地址,如下所示:
I have been working on a git repository for a while and made some commits. I have been using documentation blocks in my php files, including my private email address, like this:
/** * Bla bla bla. * * @author: Nic <foo@bar> */现在,我创建了一个新的电子邮件地址并更新了文档栏,用新的地址替换了旧地址.但是此更改仅适用于我更改了文档之后的提交.
Now I have created a new email address and updated the documentation blocks, replacing the old address with the new one. But this change only applies to commits after the one where I changed the documentation.
如何才能从git的历史记录中完全删除旧电子邮件地址,并用新地址替换所有实例?
How can I completely remove the old email address from git's history and replace all instances with the new address?
我尝试使用此博客文章,但未成功.我得到以下结果:
I have tried using git filter-branch using this blog post but without success. I get the following result:
git filter-branch --tree-filter 'git ls-files -z "*.php" |xargs -0 perl -p -i -e "s#old-email@example#new-email@foobar#g"' -- --all Usage: git core\git-filter-branch [--env-filter <command>] [--tree-filter <command>] [--index-filter <command>] [--parent-filter <command>] [--msg-filter <command>] [--commit-filter <command>] [--tag-name-filter <command>] [--subdirectory-filter <directory>] [--original <namespace>] [-d <directory>] [-f | --force] [<rev-list options>...]难道是电子邮件地址的特殊字符(@和.)弄乱了正则表达式吗?除此之外,我不知道出了什么问题,我们将不胜感激!
Could it be that the special characters of the email addresses (@ and .) are messing up the regular expression? Other than that I have no idea what's going wrong, any help is appreciated!
推荐答案另一个选择是以这种方式尝试过滤分支:
Another option is trying filter-branch this way:
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Nick NLD" ]; then export GIT_AUTHOR_EMAIL=your_new_email@example; fi; git commit-tree "$@"'更多推荐
更改Git历史记录中的电子邮件地址
发布评论