Removing Specific Files
To remove a file containing sensitive data from all of history:Removing Multiple Files
For removing many files at once, create a file listing all paths to remove:Removing Files by Pattern
Remove all files matching a specific pattern:Replace Text in Files
For removing sensitive strings embedded in files (like API keys in code):Create a replacements file
Create
../replacements.txt with the format FIND==>REPLACE:You can also use regex patterns:
Advanced: Using Callbacks
For complex removal scenarios, use Python callbacks:Remove specific blob by hash
If you know the hash of a sensitive blob:Remove files with specific patterns in name
Removing a Directory
To remove an entire directory from history:Complete Cleanup Workflow
Post-Cleanup Checklist
- All sensitive credentials have been rotated
- Force push completed successfully
- All team members notified to re-clone
- GitHub/GitLab support contacted (if needed for server-side cleanup)
- Repository size reduced as expected
- CI/CD secrets updated
- Documentation updated with new credentials (in secure storage)
