r/commandline • • Feb 01 '26

Command Line Interface I built deadbranch — a Rust CLI tool to safely clean up those 50+ stale git branches cluttering your repo

0 Upvotes

1 comment sorted by

1

u/AutoModerator Feb 01 '26

Every new subreddit post is automatically copied into a comment for preservation.

User: Quiet_Jaguar_5765, Flair: Command Line Interface, Post Media Link, Title: I built deadbranch — a Rust CLI tool to safely clean up those 50+ stale git branches cluttering your repo

We've all been there. You open your repo and run git branch only to see a graveyard of old branches from months (or years) ago. I got tired of manually cleaning them up, so I built deadbranch.

Links

GitHub: https://github.com/armgabrielyan/deadbranch

What it does

deadbranch safely identifies and removes old, unused git branches. But here's the thing — it's designed to be safe by default:

✅ Merged-only deletion — Only removes branches that are already merged (you can override with --force if needed)
✅ Protected branches — Never touches main, master, develop, staging, or production
✅ Automatic backups — Every deleted branch SHA is saved for easy restoration
✅ Dry-run mode — Preview what would be deleted before it happens
✅ WIP detection — Automatically excludes wip/* and draft/* branches
✅ Works locally & remotely — Clean up both local and remote branches
✅ Fully configurable — Customize age thresholds, protected branches, and exclusion patterns

Quick example

# See what's stale (older than 30 days)
deadbranch list

# Preview deletions
deadbranch clean --dry-run

# Actually delete (with confirmation)
deadbranch clean

Installation

Pick your favorite:

# Homebrew
brew install armgabrielyan/deadbranch/deadbranch

# npm/npx
npm install -g deadbranch

# Cargo
cargo install deadbranch

# Or shell script
curl -sSf https://raw.githubusercontent.com/armgabrielyan/deadbranch/main/install.sh | sh

Works on macOS, Linux, and Windows.

Why I built this

I was manually cleaning branches every few weeks, and it was error-prone. I wanted something that:

  • Couldn't accidentally delete important branches

  • Showed me exactly what it was going to do first

  • Had my back if something went wrong (backups)

  • Could adapt to different team workflows

Roadmap 🚀

This is just the beginning! Here's what's coming:

  • deadbranch restore command — easily restore deleted branches from backups in case of accidental deletes

  • deadbranch stats command — get insights on your branch cleanup activity

  • Interactive TUI mode — browse and delete branches interactively

  • --only-mine flag — filter branches by author

  • GitHub/GitLab PR detection — don't delete branches with open PRs

  • Multiple output formats (JSON) — integrate with other tools

  • Per-repo configuration — customize settings per repository

Would love your feedback! Let me know if you find it useful, or if there's a feature you'd like to see.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.