Remove sensitive files or patterns from git history (rewrites history!)
Removes sensitive files or patterns from git history by rewriting commits.
/plugin marketplace add iamfiscus/claude-code-scrub/plugin install iamfiscus-scrub@iamfiscus/claude-code-scrub<file_or_pattern> [--dry-run]Remove sensitive data from git history. WARNING: This rewrites history!
Execute the history scrubbing script:
bash "$CLAUDE_PLUGIN_ROOT/scripts/scrub-history.sh" <target> [--dry-run]
--dry-run or -n: Preview what would be removed without making changestarget: File path, directory, or pattern to removescrub-history.sh .env # Remove .env from all commits
scrub-history.sh secrets/ # Remove entire directory
scrub-history.sh config/prod.key # Remove specific file
scrub-history.sh 'sk_live_abc123' # Remove specific string
scrub-history.sh 'AKIA[A-Z0-9]{16}' # Remove AWS keys by pattern
After scrubbing, you must:
git push --force --all/scrub:history .env --dry-run - Preview removal/scrub:history credentials.json - Remove credentials file/scrub:history 'password123' - Remove specific stringgit-filter-repo for pattern removal (install: brew install git-filter-repo)git filter-branch works for file removal