Git:使用 bfg (beg-repo-cleaner) 删除特定文件

Yah*_*din 6 git bfg-repo-cleaner

我试图从 Git 历史记录中永久删除一个文件,因为它包含敏感数据。

为此,我使用bfghttps : //rtyley.github.io/bfg-repo-cleaner/

该文件名为app/config.json.

但是config.json,我不想删除其他文件夹中调用的其他文件。

我尝试了以下方法:

git clone --mirror git://example.com/some-repo.git
bfg --delete-files app/config.json my-repo.git
Run Code Online (Sandbox Code Playgroud)

但我收到错误消息:

Error: *** Can only match on filename, NOT path *** - remove '/' path segments
Run Code Online (Sandbox Code Playgroud)

如何仅删除此特定文件?

mad*_*ght 3

“警告:一旦您将提交推送到 GitHub,您应该考虑其中包含的任何数据都会受到泄露。如果您提交了密码,请更改它!如果您提交了密钥,请生成一个新密钥。” https://help.github.com/articles/removing-sensitive-data-from-a-repository/

cd my-repo/app
bfg --delete-files config.json
Run Code Online (Sandbox Code Playgroud)

您还可以尝试:

bfg --replace-text config.json
Run Code Online (Sandbox Code Playgroud)

  • 我按照 bfg 网站上的文档的建议做了一个 git 镜像。为此我需要做一个普通的克隆吗 (2认同)
  • 当我在存储库上运行你的命令时,它显示:“C:\path\to\some-repo\app 不是有效的 Git 存储库。” (2认同)