Worktrees are addressed by branch name; paths are computed from a configurable template. Unlike git switch, this navigates between worktrees rather than changing branches in place.
Switching to a worktree, creating one, and creating one that launches an agent
The --create flag creates a new branch from --base — the default branch unless specified. Without --create, the branch must already exist. Switching to a remote branch (e.g., wt switch feature when only origin/feature exists) creates a local tracking branch.
To complete branches from a specific remote, type its prefix before pressing Tab (e.g., wt switch origin/).
A new branch tracks the remote branch it starts from only when the two share a name: --create release --base origin/release tracks origin/release, while --create feature --base origin/release gets no upstream. Publish such a branch with git push --set-upstream origin <branch>, or set git’s push.autoSetupRemote = true once.
Other commands reach it by branch or path as usual. wt list marks it ⚐, since it isn’t at the path its branch implies, and wt step relocate offers to move it back to the template path.
Worktrees are addressed by branch name, and every argument that takes one also accepts the path of the worktree itself — resolved after the branch, so a directory never shadows a branch sharing its name. A path names what a branch cannot: a detached worktree, or one of two checkouts of the same branch. Relative paths resolve against -C and a leading ~ against the home directory, so a path worktrunk printed can be pasted back.
When called without arguments, wt switch opens an interactive picker to browse and select worktrees with live preview. The candidate set widens with --branches (local branches without worktrees), --remotes (remote branches), and --prs (open PRs/MRs — see below).
The CI column shows each row’s PR/MR CI and review status, the same as wt list --full.
Alt-p to reveal the CI and summary columns as they fill in, then paging a diff, a PR's comment thread, and the PR itself
Keybindings:
Key
Action
↑/↓
Navigate worktree list
(type)
Filter worktrees
Enter
Switch to selected worktree
Alt-c
Create new worktree named as entered text
Alt-x
Remove selected worktree/branch (never forces; not the current worktree)
Alt-y
Copy selected branch name to the clipboard
Alt-o
Open the selected row’s PR/MR URL in the browser
Alt-r
Refresh the list (pick up worktrees created elsewhere)
Esc
Cancel
Alt-1–Alt-8
Jump to a preview tab
Tab/Shift-Tab
Cycle available preview tabs forward/backward
Alt-p
Toggle preview panel
Ctrl-u/Ctrl-d
Scroll preview up/down
On macOS, Alt is the Option key; the terminal needs to send it as Meta (e.g. Terminal.app’s Use Option as Meta key).
The filter matches each row’s branch, path, and — when it has a PR/MR — the PR/MR’s number, title, and author. Typing + narrows to linked worktrees, and @ to the current worktree.
Preview tabs:
diff — One net diff from the comparison base through the current worktree: committed, staged, unstaged, and untracked changes
working — Staged, unstaged, and untracked changes against HEAD
committed — Committed changes since the comparison base
log — Recent commits; commits already on the default branch have dimmed hashes
remote⇅ — Ahead/behind diff vs upstream tracking branch
pr — The selected row’s PR/MR, for any row whose branch has one
comments — The PR/MR’s comment thread, fetched from the forge for any row whose branch has one
The comparison base is the merge-base with the default branch, or with its upstream when the local default branch lags. The picker opens on diff for local rows and pr for a PR/MR listed by --prs but not available locally. A tab with no content for the selected row has a dimmed label, and the active tab’s label is underlined. Tab and Shift-Tab skip the dimmed tabs; Alt-1 through Alt-8 open any tab directly. After you choose a tab, that choice stays active while you navigate.
Pager configuration: The preview panel pipes diff output through git’s pager. Override in user config:
~/.config/worktrunk/config.toml
[switch.picker]
pager = "delta --paging=never --width=$COLUMNS"
Hiding the preview: Set preview = false under [switch.picker] to open the picker with the preview hidden; Alt-p still shows it.
The pr:<number> / mr:<number> shortcut and the PR/MR’s web URL both resolve to its branch. For same-repo PRs/MRs, worktrunk switches to the branch directly. For fork PRs/MRs, it fetches the ref (refs/pull/N/head or refs/merge-requests/N/head) and configures pushRemote to the fork URL.
wtswitchpr:101# GitHub PR #101
wtswitchhttps://github.com/owner/repo/pull/101# ...the same PR, by URL
wtswitchmr:101# GitLab MR !101
wtswitchhttps://gitlab.com/owner/repo/-/merge_requests/101# ...the same MR, by URL
wtswitch--prs# Browse open PRs/MRs in the picker
Both work anywhere a branch is accepted, including --base. The --create flag cannot be used with a PR/MR reference since the branch already exists.
If the PR or MR is on a fork, the local branch uses its branch name directly, so git push works normally. If a local branch with that name already exists for a different ref, Worktrunk uses a prefixed branch instead. The prefixed branch can fetch the PR or MR but cannot push to the fork.
The --prs flag adds the repository’s open PRs (GitHub) or MRs (GitLab) that aren’t already in the interactive picker. Selecting one switches to it as pr:<number> / mr:<number> would.
Requires gh (GitHub), glab (GitLab), or an equivalent CLI installed and authenticated; see forge platform for Gitea, Azure DevOps, and other supported platforms.
You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.