问题描述
我试图改写历史,使用:
I'm trying to rewrite history, using:
git的过滤分支--tree过滤器'git的LS-文件-z* .PHP| xargs的-0的perl -p -i -eS#(PASSWORD1 |密码2 | PASSWORD3 )##XXXXXXXXXXX G' - --all
作为rel=\"nofollow\">本教程在而非 git的过滤分支
。创建一个 password.txt的
文件,每行一个口令是这样的:
try the BFG instead of git filter-branch...
You can use a much more friendly substitution format if you use The BFG rather than git-filter-branch
. Create a passwords.txt
file, with one password per line like this:
PASSWORD1==>xXxXx # Replace literal string 'PASSWORD1' with 'xXxXx'
ezxcdf\fr$sdd%==>xXxXx # ...all text is matched as a *literal* string by default
然后:
$ java -jar bfg.jar -fi '*.php' --replace-text passwords.txt my-repo.git
您整个存储库的历史将被扫描,并且所有的.php
文件(1MB大小的下)将有换人执行:任何匹配的字符串(不在您的最新的的提交)将被替换。
Your entire repository history will be scanned, and all .php
files (under 1MB in size) will have the substitutions performed: any matching string (that isn't in your latest commit) will be replaced.
注意解析BFG的唯一位在这里用替换的文件确实是分裂的 ==>
'字符串 - 这很可能的是不是的在您的密码 - 而且所有文字间$ p $默认PTED字面上
Note that the only bit of parsing the BFG does with here with the substitution file is to split on the '==>
' string - which probably isn't in your passwords - and all text is interpreted literally by default.
如果你想更加简洁,你可以删除 ==>
和之后的自带每行的一切(即只是有密码的)和BFG将替换字符串 *** *** REMOVED
默认情况下。
If you want to be even more concise, you can drop the '==>
' and everything that comes after it on each line (ie, just have a file of passwords) and The BFG will replace each password with the string '***REMOVED***
' by default.
该BFG通常比运行 git的过滤分支
上一个大的回购和选项都围绕这两个常见的用例定制的:
The BFG is typically hundreds of times faster than running git-filter-branch
on a big repo and the options are tailored around these two common use-cases:
- 删除疯狂大文件
- 删除密码,证书&安培;其他的私有数据
- Removing Crazy Big Files
- Removing Passwords, Credentials & other Private data
的全面披露:我是BFG回购清洁的作者的
这篇关于git的过滤分支删除字符串,但如果字符串包含$'\\和其它字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!