Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

git-branch-trimmer

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-branch-trimmer

CLI tool to detect and remove stale Git branches

latest
Source
npmnpm
Version
1.4.1
Version published
Maintainers
1
Created
Source

Git Branch Trimmer

Git Branch Trimmer Hero

A CLI tool to detect and remove stale local Git branches from your repository.

This tool analyzes your Git branches and helps you identify which ones can be safely deleted, based on whether they have remote counterparts and how long it's been since their last commit.

🛠️ Installation

Install globally using your preferred package manager:

# npm
npm install -g git-branch-trimmer

# pnpm
pnpm add -g git-branch-trimmer

⚙️ Requirements

  • Node.js 16+
  • Git installed on your system

🚀 Usage

Run in any Git repository:

git-branch-trimmer

Optional flags:

# Custom stale threshold in days (default: 30)
git-branch-trimmer --stale-threshold 60

# Dry run mode
git-branch-trimmer --dry-run

# Skip confirmation prompt
git-branch-trimmer --force

What it does:

  • Scans all local branches
  • Identifies stale ones based on:
    • Missing remote counterpart
    • Last commit older than the threshold
  • Presents an interactive menu with:
    • Last commit date
    • Remote tracking info
  • Safely removes selected branches

📸 Screenshots

1. Branch Detection

Branch Detection

2. Confirmation

Confirmation

3. Done!

Done

✨ Features

  • ✅ Detects stale branches based on:
    • No remote
    • Inactivity threshold (default: 30 days)
  • 🧠 Smart, interactive selection
  • 🎛️ Customizable CLI options
  • 🧹 Safe deletion with confirmation
  • 🎨 Clean, colored terminal output
  • 🔧 Works with any Git repo

🧾 Command Line Options

OptionDescription
-t, --stale-threshold <days>Set the threshold in days for a branch to be considered stale (default: 30)
-d, --dry-runShow what would be deleted without actually deleting
-f, --forceSkip confirmation prompt

📄 License

WTFPL

FAQs

Package last updated on 04 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts