Skip to content

ynishi/git-cleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-cleaner

Bulk cleanup of git worktrees and merged branches across multiple repositories.

Features

  • Worktree cleanup — Detect and remove worktrees that are fully merged into main with no uncommitted changes
  • Branch cleanup — Delete local branches that are fully merged into main/master
  • Safe by default — Dry-run mode shows what would be deleted before executing
  • Multi-repo scan — Scan an entire directory of git repositories at once

Install

cargo install git-cleaner

Usage

# Scan and report all cleanable items
git-cleaner scan ~/projects

# Worktree cleanup (dry-run)
git-cleaner worktrees ~/projects

# Worktree cleanup (execute)
git-cleaner worktrees ~/projects --execute

# Branch cleanup (dry-run)
git-cleaner branches ~/projects

# Branch cleanup (execute)
git-cleaner branches ~/projects --execute

# Clean both worktrees and branches
git-cleaner all ~/projects --execute

Output example

Scanning 125 repositories in /home/user/projects

arch-lint
  [DELETE] arch-lint-ts (feature/tree-sitter)
  [KEEP] arch-lint-global-config (feature/global-config) — 1 unmerged commits, uncommitted changes
  4 merged branches: feat/no-silent-result-drop, feature/global-config-v2, ...

--- Summary ---
Worktrees: 57 total, 28 removable
Merged branches: 537

Safety

  • Worktrees are only removed when:
    • All commits are merged into main/master
    • No uncommitted changes exist
  • Branches are only deleted when fully merged (git branch -d equivalent)
  • --execute flag is required for any destructive action
  • Interactive confirmation before execution

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages