Interactive TUI for cleaning up git worktrees.
Scans your repository for worktrees that are merged, stale, or detached and lets you remove them in bulk or individually — without touching your active work.
- Detects merged branches (including squash-merges)
- Detects remote-gone branches and detached HEADs
- Marks worktrees with no recent commits as stale
- Category-based bulk removal or individual selection via
fzf - Dry-run mode to preview what would be removed
- Configurable stale threshold
- Colored terminal output (degrades gracefully in non-TTY environments)
One-liner:
curl -fsSL https://raw.githubusercontent.com/mbensch/wtkill/main/install.sh | bashManual:
git clone https://github.com/mbensch/wtkill.git
cd wtkill
bash install.shBy default wtkill is installed to ~/.local/bin. Override with PREFIX:
PREFIX=/usr/local/bin bash install.shIf the install directory is not on your $PATH, the script will tell you how to add it.
wtkill [OPTIONS]
| Option | Description |
|---|---|
--dry-run |
Show what would be removed without deleting anything |
--no-fetch |
Skip git fetch --prune |
--report-only |
Print classification summary and exit (non-interactive) |
--stale-days=N |
Days of inactivity before a worktree is considered stale (default: 14) |
--update |
Update wtkill to the latest release |
--version, -V |
Print version and exit |
--help, -h |
Print help and exit |
Environment variable:
| Variable | Description |
|---|---|
GIT_WT_CLEAN_STALE_DAYS |
Override the default stale-days threshold |
- Optionally runs
git fetch --pruneto sync remote state. - Parses all worktrees via
git worktree list --porcelain. - Classifies each worktree as merged, stale, detached, or active based on merge status, squash-merge detection, remote branch existence, and last commit date.
- Presents an interactive menu to toggle categories for bulk removal, or launches
fzffor individual selection. - Removes selected worktrees with
git worktree remove --forceand runsgit worktree prune.
Lint with ShellCheck:
shellcheck wtkill install.shRun tests with bats:
bats test/Both run automatically on every PR via GitHub Actions.
