Reputation: 28931
I am trying to delete a file permanently from the Git history, because it contains sensitive data.
To do this, I am using bfg
: https://rtyley.github.io/bfg-repo-cleaner/
The file is called app/config.json
.
However there are other files called config.json
in other folders that I don't want deleted.
I tried the following:
git clone --mirror git://example.com/some-repo.git
bfg --delete-files app/config.json my-repo.git
but I get the error message:
Error: *** Can only match on filename, NOT path *** - remove '/' path segments
How do I delete just this specific file?
Upvotes: 10
Views: 8553
Reputation: 141758
The other answer is almost correct. Specify the root for bfg. Use this:
cd my-repo/app
bfg --delete-files config.json ..
The ..
tells bfg where is root. Otherwise you'll get:
. is not a valid Git repository.
Upvotes: 0
Reputation: 418
"Warning: Once you have pushed a commit to GitHub, you should consider any data it contains to be compromised. If you committed a password, change it! If you committed a key, generate a new one." https://help.github.com/articles/removing-sensitive-data-from-a-repository/
cd my-repo/app
bfg --delete-files config.json
You could also try:
bfg --replace-text config.json
Upvotes: 3