1

我知道之前有人问过这个问题,但我仍然对我需要采取的确切步骤感到困惑。

几个月前,我在 github 上的公共存储库(我拥有)中提交了一个包含敏感信息的文件。我现在必须删除这个文件以及它的任何痕迹。

具体来说,它是一个web.config包含一些数据库详细信息的文件。我需要删除连接字符串,但我很乐意删除整个文件并在需要时将其添加回来。

从那以后有很多提交。

我查看了BFG,这听起来像是适合这项工作的工具,但这并没有奏效——可能我犯了一个错误。

脚步:

git clone --mirror git://example.com/my-repo.git
bfg-1.12.15.jar --delete-files web.config  my-repo.git
cd my-repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive

git push

输出:

Counting objects: 1064, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1058/1058), done.
Writing objects: 100% (1064/1064), done.
Total 1064 (delta 775), reused 289 (delta 0)

Everything up-to-date

该文件仍然存在,我究竟需要做什么才能web.config从存储库中删除该文件?

更新

好的,因此建议删除 web.config,然后重新运行命令:

rm web.config 
git commit -am "removed web config"
git push

然后我重新运行了上面的所有命令,我得到了:

Using repo : xxx.git

Found 246 objects to protect
Found 2 commit-pointing refs : HEAD, refs/heads/master

Protected commits
 -----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 1f4ad898 (protected by 'HEAD')

Cleaning
--------

Found 114 commits
Cleaning commits:       100% (114/114)
Cleaning commits completed in 93 ms.

BFG aborting: No refs to update - no dirty commits found??

更新 2

原来 BFG 工作正常,我不小心输入了web.config小写而不是实际的Web.config. 无论如何它已经解决了我的问题:)

4

2 回答 2

2

您描述的步骤似乎是使用 BFG 工具的正确方法(根据他们的文档)。

请注意,BFG Repo Cleaner 只会影响存储库的历史记录,不会触及提交历史记录中的最新提交。换句话说,需要先清理分支的尖端,然后运行 ​​BFG 工具。

根据您当前的状态,首先使用 or 清理事物的当前状态git rm web.config,提交您的更改,将所有内容向上推送,然后运行 ​​BFG 以清理历史记录。

于 2017-02-07T21:33:54.040 回答
0

cd 到目录,然后,

git rm web.config

ls 检查“web.config”是否被删除

git status

您可能需要从 repo 中提取更新

于 2017-02-07T21:09:10.113 回答