gitgithubgit-filter-branchbfg-repo-cleanergit-filter-repo

Deleting a file that contains some sensitive data from Git history


How can I delete appsettings.json file from Git history?

I have applied this command in Git:

$git filter-branch --index-filter 'git rm --cached --ignore-unmatch appsettings.json' HEAD

But It does not work with this version of Git(2.30.0.windows.1)

How can I solve it?

if I want to use git-filter-repo instead git-filter-branch, how can I install and use it for my case?

$git filter-branch


Solution

  • I have used bfg-repo-cleaner.

    Follow these steps:

    1- Install Java on your system (for me is Windows 10).

    2- Download bfg-repo-cleaner. I have downloaded bfg-1.13.1 and located it in the project folder.

    3- In the Git Bash type this command:

    java -jar bfg-1.13.1.jar --delete-files appsettings.json
    

    after executing you can see some information like this: executing bfg command

    4- And finally type in the Git Bash this command:

    $ git pull
    $ git push