worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

wt switch: support --guess behavior for remote tracking branches

Open SokiKawashima opened this issue 9 months ago • 6 comments

First off, thanks for building worktrunk — it's been a fantastic tool and has genuinely improved my daily workflow.

Feature request: wt switch support for remote tracking branches (à la git switch --guess)

When I want to create a worktree for a remote branch that doesn't exist locally yet (e.g. a teammate's branch), I currently have to do:

git fetch
git switch -c feature/foo origin/feature/foo   # create local branch
git switch main                                 # go back to main
wt switch feature/foo                           # now create the worktree

It would be great if wt switch feature/foo could automatically create a local tracking branch from origin/feature/foo when no local branch exists — mirroring the --guess behavior that git switch has enabled by default.

With that, the workflow would collapse to just:

git fetch
wt switch feature/foo

This comes up frequently when working in teams where you need to check out or review branches others have pushed.

SokiKawashima avatar Feb 17 '26 06:02 SokiKawashima

this should work already! does it not? it shouldn't require the --guess

@claude do we have examples of this in docs?

max-sixty avatar Feb 17 '26 07:02 max-sixty

Claude finished @max-sixty's task in 1m 23s —— View job


  • [x] Search docs and help text for remote tracking branch / --guess examples
  • [x] Summarize findings

Findings

Yes — the behavior is documented, but only briefly. There's a single sentence in the wt switch help text (after_long_help in src/cli/mod.rs:273, synced to docs/content/switch.md and skills/worktrunk/reference/switch.md):

Without --create, switching to a remote branch (e.g., wt switch feature when only origin/feature exists) creates a local branch tracking the remote — this is the standard git behavior and is preserved.

However, there are no examples showing this workflow. The Examples section only covers --create usage. An example like this could be added:

# Switch to a teammate's branch that only exists on the remote
git fetch
wt switch feature/foo

Let me know if you'd like me to add an example to the docs.

worktrunk-bot avatar Feb 17 '26 07:02 worktrunk-bot

Oh, you're right — I had tried wt switch -c branch origin/branch (mimicking git switch -c) and assumed it wasn't supported when that failed. Just tested wt switch branch without -c and it works perfectly. Sorry for the noise, and thanks for the quick response!

SokiKawashima avatar Feb 17 '26 07:02 SokiKawashima

no prob @SokiKawashima , thanks for raising

max-sixty avatar Feb 17 '26 07:02 max-sixty

Let me know if you'd like me to add an example to the docs.

yes please @claude

max-sixty avatar Feb 17 '26 07:02 max-sixty

Claude finished @max-sixty's task in 8m 25s —— View job • claude/issue-1076-20260217-0735 • Create PR ➔


  • [x] Read src/cli/mod.rs to find the switch command's after_long_help section
  • [x] Add an example for switching to a remote tracking branch
  • [x] Run doc sync test to update generated docs
  • [x] Run full tests to verify nothing is broken
  • [x] Commit and push changes

Added a remote tracking branch example in two places in the wt switch help text:

  1. Examples section — added wt switch feature/foo with a comment noting it creates a local tracking branch
  2. Creating a branch section — added a mini-example showing the git fetch + wt switch workflow right after the existing prose about remote branch behavior

All three files updated: src/cli/mod.rs (source of truth), docs/content/switch.md, and skills/worktrunk/reference/switch.md (auto-synced).

worktrunk-bot avatar Feb 17 '26 07:02 worktrunk-bot