Feature: checkout command
Hello,
I know that wt is more focused on local AI worktree usage but it could become the tool to use for working with worktrees.
My request is for a wt checkout command that:
- pops up a fzf style dialog with the remote branches
- when selected, checks out the remove branch
The major gotcha to this command is when people use / in their branch names, eg max/feature-foo, the git reference does not like /. git will add a reference under .bare/worktrees for the worktree.
Your final tree should look like (notice .bare/worktrees/max-feature-foo):
.
├── .bare
│ └── worktrees
│ └── max-feature-foo <---- converted '/' to '-'
├── main
└── max
└── feature-foo
instead of:
.
├── .bare
│ └── worktrees
│ └── max
│ └── feature-foo <--- this will fail all git commands
├── main
└── max
└── feature-foo
Thanks for the suggestion! This is a feature request rather than a bug, so I'll leave it for a maintainer to evaluate and prioritize.
does wt switch --remotes do this?
Thanks for pointing that out and it should work but it does not.
Would you like a new bug report on what I am seeing?
Steps:
wt switch --remotes- interactive with all origin branches shows up
- select branch named
origin/username/feature-1 No branch named origin/username/feature-1
Branch definitely exists and main is updated with latest references.
ah, that is not good; I think that is indeed a bug, apologies.
@worktrunk-bot could you please triage?
Triaged and fixed in #1266.
Root cause: When the interactive picker returns a remote branch name like origin/username/feature-1, it's passed directly to resolve_switch_target. The code then looks for refs/heads/origin/username/feature-1 (local) and refs/remotes/*/origin/username/feature-1 (remote pattern) — both wrong patterns that never match.
Fix: Before resolving the branch, detect remote-tracking ref names via git rev-parse --verify refs/remotes/<name> and strip the remote prefix (e.g., origin/) so DWIM can create a local tracking branch normally. This handles branch names with / correctly by matching against the configured remote names.
The same fix also works for wt switch origin/feature from the CLI, not just the picker.