@scripting-bear/git-ignore-clean-history
v1.0.4
Published
🧹 Remove previously committed files that should have been ignored via .gitignore — interactively and safely.
Maintainers
Readme
🧹 Git Ignore Clean History
Remove previously committed files that should have been ignored via .gitignore — interactively and safely.
🔗 npx:
npx @scripting-bear/git-ignore-clean-history💡 Why?
Ever cloned a repo and realized:
- Someone committed
node_modules,.env,.DS_Store, orPods/? - Now the repo is bloated, slow, and filled with junk?
This tool helps you:
✅ Analyze your Git history
✅ Match committed files against .gitignore
✅ Confirm what should be deleted
✅ Safely rewrite history with git-filter-repo
⚙️ What It Does (Steps)
- Extract all files ever committed in Git history
- Match them against
.gitignorerules (including deep paths) - Prompt you to confirm
- Run
git-filter-repoto remove them from history - You force-push a clean repo ✨
🧪 Example
npx @scripting-bear/git-ignore-clean-history --verboseInteractive output:
📦 Step 1: Extracting all files ever committed...
✅ Extracted 20,387 unique file paths to 'all-ever-files.txt'.
👀 Do you want to continue to match these files with .gitignore? [y/N]: y
✅ Found 37 ignore patterns.
✅ Matched 643 files.
📝 Matches written to 'files-to-remove.txt'.
⚠️ Do you want to clean them from history? [y/N]: y🛠 Requirements
- Git installed
- Python 3.6+
git-filter-repo
If git-filter-repo is missing, the tool will prompt to download it.
👤 Author
Made with frustration by @scripting-bear
🤝 With technical assistance, scripting support & optimization from ChatGPT by OpenAI.
🙌 Inspired by
🔒 Note: This tool rewrites history. Push your cleaned repo with force, and share a note with collaborators.
