Here is the procedure that works the best while being the least destructive
- Open the repo using a new Codespace
- Using the terminal, download BFG tool.
cd ..
curl https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar bfg.jar
- IMPORTANT Clone a mirror of the repo (the git database only) so we don't mess with any local files
git clone --mirror <https://github.com/orgname/repo>
- Create a search file containing the secret values to replace
secretvalue==>replacementvalue
- Run the BFG replace text command on the mirrored repo
java -jar bfg.jar -rt secret.txt path-to-repo.git
- Now switch to the mirrored repo directory and clean up the reflogs
git reflog expire --expire=now --all && git gc --prune=now --aggressive
- Finally, push the changes back to the remote.
git push
git log -S "secretvalue" --all --source