Tiny VS Code extension: create, list, remove, and open git worktrees. One job.
Local-only. No AI. No cloud. No account. MIT licensed.
Run (F5)
Open /home/box/worktree-switch in VS Code / Cursor.
Install dependencies, then compile (see commands below). F5 also compiles via the default build task.
Press F5 to launch the Extension Development Host.
In the new window, open a git repository. Click the Worktrees activity bar icon (two-node worktree). The tree lists git worktree list.
Use + in the view title to add a worktree. Right-click a worktree to Open (new window) or Remove.
Behavior
Tree is git worktree list --porcelain.
Add: QuickPick of local branches, plus New branch…. Picking a branch that already has a worktree errors instead of duplicating. New branch… prompts for a name (if that name already exists locally, it is treated as an existing branch — no -b). Creates a sibling folder <parent>/<repoName>-<sanitized> (slashes become hyphens: feat/foo -> myrepo-feat-foo), runs git worktree add (existing branch) or git worktree add -b (new branch), then opens that folder in a new VS Code window.
Open: selected worktree folder in a new window.
Remove: confirms with a modal, then git worktree remove <path> (no --force). Will not remove the main checkout (.git directory, not a .git file).
If git fails, stderr is shown and the command stops. Errors are not swallowed.
If the workspace is not a git repo, the tree shows Open a git repository.
Layout
src/extension.ts — activate, commands
src/worktreeProvider.ts — tree + add/remove/open
src/git.ts — spawn git with an args array; throw including stderr
Install: npm install
Compile: npm run compile (or just F5, which compiles)