gitreaper

module
v0.0.0-...-46d0c3d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2025 License: MIT

README ΒΆ

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.

Go Version License GitHub Actions Latest Release


⚑️ 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

Directories ΒΆ

Path Synopsis
cmd
gitreaper command
internal
cli
git
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL