更改Git历史记录中的电子邮件地址

编程入门 行业动态 更新时间:2024-10-23 03:14:24
本文介绍了更改Git历史记录中的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在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历史记录中的电子邮件地址

本文发布于:2023-10-28 01:04:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535042.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:历史记录   电子邮件地址   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!