GitReaper β οΈ
Clean up your Git repository like a pro.
GitReaper safely reaps stale, merged, or orphaned branches and cleans your workspace with intelligent, configurable rules.

β‘οΈ Features
- π Dry run mode with color-coded output
- π§Ή Delete local branches merged into
main, master, or develop
- π« Automatically protect important branches (via
.gitreaperrc)
- π
Age-based cleanup (
--older-than, --keep-recent)
- π§ Interactive mode with commit info and author context
- π₯
--force, --aggressive cleanup for CI or cron
- π Post-cleanup reports: what was deleted and how much space was saved
- πͺ Git hook integration (e.g., run before
git push)
- π Configurable per-repo or globally
π¦ Installation
Using go install:
go install github.com/yourusername/gitreaper@latest
Make sure $GOPATH/bin is in your $PATH.
Or build from source:
git clone https://github.com/yourusername/gitreaper.git
cd gitreaper
make build
./build/gitreaper --help
π Usage
gitreaper --dry-run
Example:
gitreaper --older-than 30d --exclude "release/*" --interactive
Available flags:
| Flag |
Description |
--dry-run |
Preview deletions without making changes |
--older-than |
Clean branches older than X days |
--keep-recent |
Keep branches modified in last X days |
--force |
Skip all confirmations |
--interactive |
Show branch-by-branch prompt |
--config |
Use custom config file |
π‘ Configuration (.gitreaperrc)
Create a .gitreaperrc file in your repo root or ~/.gitreaperrc:
protect = ["main", "master", "develop", "release/*"]
dry_run = true
interactive = true
older_than_days = 30
π Project Structure
gitreaper/
βββ cmd/gitreaper # CLI entrypoint
βββ internal/ # App logic modules
β βββ git/ # Git command wrappers
β βββ reaper/ # Branch cleanup logic
β βββ config/ # Config parsing
β βββ ui/ # Interactive prompts, output
β βββ errors/ # Custom error handling
βββ pkg/ # Exportable packages
βββ docs/ # Project documentation
βββ scripts/ # Dev tools and helpers
βββ testdata/ # Test fixtures
βββ .github/workflows/ # CI/CD configs
βββ .gitignore
βββ LICENSE
βββ Makefile
βββ README.md
π§ͺ Testing
Run all tests:
make test
π§° Development
Install dependencies:
make deps
Run linter:
make lint
π License
This project is licensed under the MIT License. See the LICENSE file for details.
β¨ Future Roadmap
- GitHub remote branch cleanup
- GUI or TUI interface (fzf-style)
- VS Code extension
- Auto-scheduling or daemon mode