Remove sensitive files in git history
- Filter the branch to remove the sensitive files/folders (eg.
FILE1andFOLDER1) from history:
Note: I don’t know how to adapt if there are several branches.
- Push the changes to the branch of interest (eg.
main):
From StackOverflow:
After filter-branch, Git keeps refs to the old commits around, in case something goes wrong.
- Clean these references (eg, on the branch
main):