gw is short for "go worktree". It resolves a local Git branch to the worktree
that has it checked out, or switches the primary worktree to that branch when no
linked worktree exists.
The executable prints a destination path. To make gw branch-name change your
interactive shell directory, install a shell wrapper.
For zsh or bash:
gw() {
case "$1" in
""|-h|--help|--version)
command gw "$@"
return
;;
esac
local dest
dest="$(command gw "$@")" || return
cd "$dest" || return
}For fish, add this to ~/.config/fish/config.fish or
~/.config/fish/functions/gw.fish:
function gw
switch "$argv[1]"
case "" -h --help --version
command gw $argv
return
end
set -l dest (command gw $argv)
set -l gw_status $status
if test $gw_status -ne 0
return $gw_status
end
cd "$dest"
endInstall the binary with:
cargo install --path .Then add the shell wrapper to your shell config after the binary is on PATH.
gw feature/nfc-piece-rate-captureBehavior:
- Matches exact local branch names only.
- If the branch is checked out in any worktree, changes to that worktree root.
- If the branch exists locally but has no worktree, runs
git switch <branch>in the primary worktree and changes to that primary worktree root. - If run from a subdirectory, still changes to the target worktree root.
gw does not fetch, create branches, create worktrees, or fuzzy-match branch
names.