git-wt

Fast, reliable git worktree management

Language
Go
Version
0.12.0
License
MIT
Category
Dev Tool

A CLI tool for managing git worktrees with automatic setup, configuration copying, and interactive navigation. It automates branch creation, safely removes worktrees with cleanup, and syncs configuration files across worktrees.

Preview

>_

Features

01

Create worktrees with automatic branch creation and config copying (default layout: <repo>/.worktrees/<leaf>/)

02

Add command for existing branches — local or remote refs (auto-creates tracking branch)

03

Eject — move the currently-checked-out branch into a new worktree, stashing & restoring uncommitted changes, then switch main tree back to main/master

04

Remove worktrees safely with multi-select support and branch cleanup

05

Interactive navigation between worktrees sorted by modification time

06

Auto-syncs .env, .claude, CLAUDE.local.md, and .ai-cache to new worktrees (customizable via .git-wt-copy-files)

07

Clean stale worktrees for branches deleted from remote (orphaned or upstream-gone, with auto fetch --prune)

08

Persistent settings via git config wt.* with ${repo}/${repoPath}/${repoParent}/${home} templating

09

Shell tab-completion — bash/zsh/fish/PowerShell with dynamic candidate completion

10

Shell alias generation with configurable file descriptor (fd3 by default), auto-bound completion

11

Nested subdirectories for branch names with slashes

12

Bare mode — works without shell alias, outputs paths for copy-paste or piping

13

Zero runtime dependencies (except git)

Install

Homebrew

>_
$ brew install shhac/tap/git-wt

GitHub Release (macOS)

>_
$ curl -L https://github.com/shhac/git-wt/releases/latest/download/git-wt-macos-universal.tar.gz | tar xz

Build from Source

>_
$ git clone https://github.com/shhac/git-wt.git && cd git-wt && go build -o git-wt ./cmd/git-wt

Getting Started

CLI tools run as subprocesses and can't change your shell's working directory. The gwt shell alias wraps git-wt with a file descriptor mechanism so that commands like new and go actually navigate your shell to the worktree.

01 · Add the alias to your shell config

>_
$ echo 'eval "$(git-wt alias gwt)"' >> ~/.zshrc

For bash, use ~/.bashrc instead. You can replace gwt with any name you prefer.

02 · Reload your shell

>_
$ source ~/.zshrc

03 · Use gwt for all commands

gwt new and gwt go will change your shell's directory. Other commands like list and clean pass through unchanged.

Usage

>_ Create a worktree with nested branch
$ gwt new feature/auth-system
>_ Add a worktree for an existing remote branch
$ gwt add origin/paul/auth-bug
>_ Eject the current branch into a new worktree
$ gwt eject
>_ Interactive worktree navigation
$ gwt go
>_ Multi-select removal
$ gwt rm
>_ List worktrees (plain output for piping)
$ gwt list --plain
>_ Preview stale worktree cleanup
$ gwt clean --dry-run