首页 > 解决方案 > 使用bfg的参数是什么

问题描述

我正在尝试使用bfg从我的 git repo 中清除一些东西。作者的指示建议

java -jar bfg --replace-text passwords.txt  my-repo.git

我理解这些是什么意思

java -jar bfg.jar --replace-text <some text?> <a directory?>

但是我所有提供文本和目录的努力都会出错Error: Option --replace-text failed when given 'some-text'. some-text (No such file or directory)。有没有人弄清楚如何使用bfg?

我的目标是从我的历史记录中删除一个短字符串(可能只出现在一个文件中,但我不能确定)

标签: gitbfg-repo-cleaner

解决方案


rtyley/bfg-repo-cleaner问题 154提供了以下示例:

因此,您创建了一个名为 eg的文件replacements.txt,并将类似这样的内容放入其中 - 每个密码、凭据等一行:

PASSWORD1 # Replace literal string 'PASSWORD1' with '***REMOVED***' (default)
PASSWORD2==>examplePass         # replace with 'examplePass' instead
PASSWORD3==>                    # replace with the empty string
regex:password=\w+==>password=  # Replace, using a regex

...然后运行 ​​BFG,指定替换文件:

$ java -jar bfg.jar  --replace-text replacements.txt  my-repo.git

您应该将短字符串放入测试文件中。


推荐阅读