Skip to content

krystxf/worktree-workflow

Repository files navigation

wtw — Go CLI

Install

Homebrew

brew tap krystxf/wtw
brew install wtw

Configuration

Global config

Create ~/.config/worktree-workflow/config.json:

{
  "editor": "cursor",
  "auto_open_editor": true,
  "naming": {
    "worktree_dir_suffix": "--worktrees",
    "branch_separator": "--"
  }
}
Field Default Description
editor "cursor" Command to open the worktree (e.g. code, nvim, zed)
auto_open_editor true Open editor automatically after creating a worktree
naming.worktree_dir_suffix "--worktrees" Suffix for the parent worktree directory
naming.branch_separator "--" Separator between repo name and branch name

All fields are optional — missing values use the defaults above.

Per-project config

Create .worktree-workflow.json in your project root:

{
  "sync_ignored": true,
  "sync_excludes": ["node_modules"],
  "post_copy_hooks": ["npm install"]
}
Field Default Description
sync_ignored true Sync gitignored files (.env, etc.) via hard links
sync_excludes [] Patterns to exclude from sync
post_copy_hooks [] Shell commands to run in the new worktree after creation

Examples

See the examples/ directory:

  • cursor-npm — Cursor editor + npm install
  • tmux — tmux window per worktree

Development

Prerequisites

  • Go 1.21+
  • git
  • rsync (pre-installed on macOS/Linux)

Build

git clone https://github.com/krystof/worktree-workflow.git
cd worktree-workflow
go build -o wtw .

This produces a wtw binary in the current directory.

Run locally

# Create a worktree
./wtw create feature-branch

# List worktrees (interactive picker)
./wtw ls

# Remove a worktree
./wtw rm feature-branch

Make targets

# Build
make build

# Format code
make fmt

# Lint (requires golangci-lint)
make lint

# Clean binary
make clean

E2E tests

Tests run inside a Docker container to ensure a consistent, isolated environment.

Prerequisites: Docker

make e2e-docker

This builds the binary inside the container, runs all tests, and prints a colored summary at the end.

Install golangci-lint

brew install golangci-lint

Or see golangci-lint.run for other methods.

About

Create, list, and remove git worktrees with a TUI picker. Syncs gitignored files (`.env`, etc.) to new worktrees via hard links and runs post-copy hooks (e.g. `npm install`).

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages