A fast CLI tool for managing git worktrees with fuzzy selection.
- Quick worktree creation with optional branch name preprocessing
- Interactive fuzzy finder for navigating between worktrees
- Multi-select deletion of worktrees
- File copying with gitignore-style patterns
- Post-creation hooks for automated setup
- Shell integration for seamless directory switching
- Tmux support for opening worktrees in new panes
brew install default-anton/tap/wtDownload the latest release from GitHub Releases.
go install github.com/default-anton/wt/cmd/wt@latestFor wt cd and wt add to automatically change your directory, add shell integration.
Note: If installed via Homebrew, shell integration and completions are set up automatically. You can skip this section.
# Add to ~/.bashrc
eval "$(wt shell-init bash)"
eval "$(wt completion bash)"# Add to ~/.zshrc
eval "$(wt shell-init zsh)"
eval "$(wt completion zsh)"# Add to ~/.config/fish/config.fish
wt shell-init fish | source
wt completion fish | source# Create worktree with branch name
wt add my-feature
# With tmux (opens in new pane)
wt add my-feature -t # or --tmux
# With custom base branch
wt add my-feature --base develop# Interactive fuzzy finder
wt cd
# With tmux
wt cd -t # or --tmux# Interactive multi-select
wt rm
# Direct removal
wt rm .worktrees/my-feature
# Force removal
wt rm -f .worktrees/my-featurewt lswt initRun wt init to create a .wt.toml configuration file in your repository root. This command also adds the worktree directory to .gitignore.
Example configuration:
# Base branch for new worktrees (default: main)
base_branch = "main"
# Directory for worktrees (default: .worktrees)
worktree_dir = ".worktrees"
# Preprocessing script (receives input, outputs branch name)
preprocess_script = ".wt/preprocess.sh"
# Files/directories to copy (gitignore-like patterns)
# Supports ** for recursive matching (e.g., **/node_modules for monorepos)
copy_patterns = [
"**/node_modules",
".env*",
"vendor",
"!.env.example",
]
# Post-creation hooks
[[post_hooks]]
name = "Install dependencies"
run = "npm install"
[[post_hooks]]
name = "Setup database"
run = "bin/rails db:prepare"
if_exists = "bin/rails"You can define a script that transforms the input into a branch name. This is useful for extracting branch names from issue tracker URLs:
#!/bin/bash
# .wt/preprocess.sh
# Example: Extract JIRA ticket from URL
# Input: https://jira.example.com/browse/PROJ-123
# Output: PROJ-123-feature-name
INPUT="$1"
# Extract ticket ID from URL or use as-is
if [[ "$INPUT" =~ ([A-Z]+-[0-9]+) ]]; then
TICKET="${BASH_REMATCH[1]}"
echo "$TICKET"
else
echo "$INPUT"
fiMake sure the script is executable: chmod +x .wt/preprocess.sh
MIT License - see LICENSE for details.