Git: How to Remove Keys and Secrets from Your Repository's History

Опубликовано: 13 Август 2026
на канале: The Machine Learning Engineer
660
18

In this video we're going to look at how to remove private information, secrets, or history keys from your Git repository. For this we will use the BFG tool.

Commands:

1) Install Java JRE and download BFG from the following URL --
https://rtyley.github.io/bfg-repo-cle...

2) Clone your repository with --
git clone --mirror https://github.com/olonok69/test_clea...

3) Create a txt file with the keys, credentials, private information that you want to delete, this example pass.txt.

4) Run the BFG program in text replacement mode. This example --
java -jar bfg.jar --replace-text pass.txt test_cleaner.git

5) Enter the directory, this example --
cd test_cleaner.git

6) Deploy changes to the repository and clean up. This example --
git reflog expire --expire=now --all
and
git gc --prune=now --aggressive

7) Upload the clean repository to GitHub --
git push.

credits to https://rtyley.github.io/bfg-repo-cle...