我知道之前有人问过这个问题,但我仍然对我需要采取的确切步骤感到困惑。
几个月前,我在 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
. 无论如何它已经解决了我的问题:)