Git Repo Cleaner
Audit Git repositories for bloat, stale branches, and maintenance issues. Generate safe cleanup scripts.
Quick Audit
python3 scripts/audit_repo.py /path/to/repo
Specific Checks
# Stale branches only
python3 scripts/audit_repo.py /path/to/repo --check branches
# Large files in history
python3 scripts/audit_repo.py /path/to/repo --check large-files
# Full audit
python3 scripts/audit_repo.py /path/to/repo --check all
Output Formats
python3 scripts/audit_repo.py /path/to/repo --format text|json|markdown
Checks Performed
1. Stale Branches
- Branches not updated in >30 days (configurable with
--stale-days) - Branches already merged into main/master
- Branches with no unique commits
- Remote tracking branches with deleted remotes
2. Large Files
- Files >1MB in current tree (configurable with
--min-size) - Large blobs in git history (top 20)
- Binary files that shouldn't be tracked
3. Repo Stats
- Total repo size (.git directory)
- Pack file stats
- Object count and size
- Unreachable objects
4. Maintenance
- Missing .gitignore patterns (node_modules, pycache, .env, etc.)
- Unoptimized packfiles
- Stale reflog entries
Cleanup Script Generation
Use --fix to generate (not execute) cleanup scripts:
python3 scripts/audit_repo.py /path/to/repo --fix
# Outputs cleanup.sh with safe delete commands
The generated script uses git branch -d (safe delete, refuses if not merged) by default.
Use --force-delete to generate git branch -D commands instead.
Workflow
- Run audit on repo
- Review findings
- Generate cleanup script if needed
- Review script before executing
- Execute cleanup
