git-worktree-runner (a.k.a. git-gwr) is a Go port of github.com/coderabbitai/git-worktree-runner with some additional features.
This project builds a Git subcommand binary named git-gwr (so you run it as git wr ...).
- Git installed (and new enough for
git worktree). - Go 1.25+ (only needed to build from source).
go install github.com/zchee/git-worktree-runner/cmd/git-gwr@latestgit clone https://github.com/zchee/git-worktree-runner.git
cd git-worktree-runner
make build/git-gwr
# Ensure the `git-gwr` binary is on your PATH.
# Example (macOS/Linux):
ln -sf "$(pwd)/bin/git-gwr" /usr/local/bin/git-gwr
# or
sudo ln -sf "$(pwd)/bin/git-gwr" /usr/local/bin/git-gwrcd /path/to/your/repo
# Optional one-time setup (per repo or --global)
git wr config set gwr.editor.default cursor
git wr config set gwr.ai.default claude
# Create a worktree for a branch (creates a sibling folder by default)
git wr new feature-auth --yes
# List worktrees
git wr list
git wr list --porcelain # path<TAB>branch<TAB>status
# Navigate (shell-friendly)
cd "$(git wr go feature-auth)"
# Run a command in a worktree directory (exit code propagates)
git wr run feature-auth git status
# Remove the worktree
git wr rm feature-auth --yesThe CLI targets upstream parity for the core UX:
git wr new <branch> [options]— create a worktreegit wr rm <id|branch|worktree-name>... [options]— remove worktree(s)--delete-branchprompts before deleting the branch (skip prompts with--yes)
git wr go <id|branch|worktree-name>— print absolute path to stdoutgit wr run <id|branch|worktree-name> <command...>— run command in that directorygit wr list [--porcelain]— list main repo + worktreesgit wr copy <target>... [options] [-- <pattern>...]— copy files between worktreesgit wr editor <id|branch|worktree-name> [--editor <name>]git wr ai <id|branch|worktree-name> [--ai <name>] [-- args...]git wr clean— prune stale worktrees and remove empty directories in the configured base dirgit wr doctor— basic health checkgit wr adapter— list built-in adapters and availabilitygit wr config {get|set|add|unset} <key> [value] [--global]git wr version,git wr help
Configuration is resolved with this precedence (highest to lowest):
- local git config (
.git/config) .gwrconfig(repo root, gitconfig syntax)- global git config (
~/.gitconfig) - system git config
- environment variables
- hard-coded defaults
Common keys:
gwr.worktrees.dir: base directory for worktrees- default:
<repo-parent>/<repo-name>-worktrees - supports absolute paths, repo-relative paths, and
~expansion
- default:
gwr.worktrees.prefix: prefix added to each worktree folder namegwr.defaultBranch:auto|main|master|<branch>gwr.editor.default: editor adapter name ornonegwr.ai.default: AI adapter name ornonecursor: preferscursor-agent, then triescursor cli(varies by Cursor version), then falls back tocursor
gwr.copy.include/gwr.copy.exclude(multi): file globs for copyinggwr.copy.includeDirs/gwr.copy.excludeDirs(multi): directory copy rulesgwr.hook.postCreate/gwr.hook.postRemove(multi): hook commands
Environment variables supported:
GTR_WORKTREES_DIRGTR_WORKTREES_PREFIXGTR_DEFAULT_BRANCHGTR_EDITOR_DEFAULTGTR_AI_DEFAULT
make test
make fmt
make lintThis repository uses integration-style tests (real git, real filesystem; no mocks).
Upstream ships completion scripts; this Go port includes equivalents in ./completions/:
- Zsh:
completions/_git-gwr- Install: copy/symlink into a directory in your
$fpath(example:~/.zsh/completions/), then runautoload -Uz compinit && compinit.
- Install: copy/symlink into a directory in your
- Bash:
completions/gwr.bash- Install: add
source /path/to/git-worktree-runner/completions/gwr.bashto your~/.bashrc.
- Install: add
- Fish:
completions/gwr.fish- Install:
ln -s /path/to/git-worktree-runner/completions/gwr.fish ~/.config/fish/completions/thenexec fish.
- Install:
Example configuration and helper scripts live under ./templates/:
templates/.gwrconfig.example→ copy to<repo-root>/.gwrconfig(gitconfig syntax)templates/gwr.config.example→ reference for commongit configkeystemplates/setup-example.sh→ example one-time repo setup (git config --local ...)templates/run_services.example.sh→ example “run multiple services” helper