[英]Git apply a change to all files in all previous commits
我想对我的 git 历史记录中的所有文件应用更改。 更准确地说,我想修改一个特定的行,即作者姓名(它写在我所有文件的 header 中,我不是在谈论 git 作者)从所有 ZBA9F11ECC3492BD61E5Z 历史记录中删除以前的值并更改它由新的。
到目前为止,我已经尝试使用git filter-branch
来执行以下命令: sed -i -e "s/<previous_author>/<new_author>/"
当我在单个文件(<previous_author>确实被文件中的 <new_author> 替换)。
但是,当我使用git filter-branch -f --tree-filter 'sed -i -e "s/<previous_author>/<new_author>/"' HEAD
时,我收到错误sed: -i may not be used with stdin
. 我试图用git rebase
做类似的事情,但我得到了同样的错误。
那么有没有办法做到这一点,所以要对我之前提交的所有文件执行sed -i -e "s/<previous_author>/<new_author>/"
? 提前致谢。
你可以尝试类似的东西
git filter-branch -f --tree-filter \
'if git grep --name-only "@author";
then
git grep --name-only "@author" | xargs sed -i -e "s/@prev_auth/@new_author/"
fi'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.