Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Delete a specific file using bfg (beg-repo-cleaner)

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?

like image 848
Yahya Uddin Avatar asked Jul 20 '17 15:07

Yahya Uddin


People also ask

How do I remove a file from my git repository?

Simply view any file in your repository, click the trash can icon at the top, and commit the removal just like any other web-based edit. Then " git pull " on your local repo, and that will delete the file locally too.

What is BFG repo cleaner?

Removes large or troublesome blobs like git-filter-branch does, but faster - and written in Scala - Fund the BFG. $ bfg --strip-blobs-bigger-than 1M --replace-text banned.txt repo.git.


1 Answers

"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
like image 99
madnight Avatar answered Sep 28 '22 02:09

madnight