Skip to content

Instantly share code, notes, and snippets.

@hemanth22
Last active March 23, 2021 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hemanth22/1ee9b50056d8699d143e0425b992d988 to your computer and use it in GitHub Desktop.
Save hemanth22/1ee9b50056d8699d143e0425b992d988 to your computer and use it in GitHub Desktop.
git rewrite history
  1. First Go to below website link:

https://rtyley.github.io/bfg-repo-cleaner/

  1. Download the bfg.jar file.
  2. Place this file where repo has leaked secrets.
  3. Execute below command with filename which contain leaked secrets
java -jar bfg-1.14.0.jar .git --delete-files *terraform.tfstate.backup*
  1. After executing above command, create any empty file to commit new changes in the history to repo.
  2. This will re-write the history and there won't be any leaked secret keys in the history

Tips:

https://medium.com/@vs28031996/remove-git-history-with-bfg-repo-cleaner-866808826eea
https://stackoverflow.com/questions/49580624/correct-usage-of-bfg-repo-cleaner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment