Efficiently move selected file changes between Git branches and worktrees without stashing your entire working tree.
Features
- SCM Integration: Right-click one or more files in the Source Control Changes list and select "Patch to Worktree..." to apply those specific changes to another branch or worktree
- Multi-Select Support: Select multiple files from SCM and patch them all at once
- Smart Worktree Discovery: Automatically detects and lists all worktrees in your workspace, organized by repository
- Untracked File Handling: Gracefully handles untracked files using Git's intent-to-add feature
- Safe Application: Validates patches with a preflight check before applying, using 3-way merge for maximum resilience
- Last Target Memory: Remembers your last chosen target worktree for quick repeated operations
Use Case
Working on a large repository with a very dirty working tree? Need to move only 1–N specific changed files to another branch without stashing everything?
Instead of:
git stash- Switch branch
git stash pop- Commit
- Stash again
- Switch back
- Pop again
Just:
- Select your files in SCM
- Right-click → "Patch to Worktree..."
- Pick your target
- Done ✓
Requirements
- VS Code 1.110.0 or later
- Git installed and available in your PATH
- A Git repository with one or more worktrees (or just multiple branches)
How to Use
- Open the Source Control view in VS Code
- Select one or more files in the "Changes" section
- Right-click and choose Patch to Worktree...
- Select the target worktree or repository branch from the Quick Pick
- The extension will:
- Generate a patch from only the selected files
- Validate the patch can be applied
- Apply it with 3-way merge support
- Restore your source repository state
Known Limitations
- Only SCM selection is supported; Explorer selection is not used
- All selected files must be in the same Git repository
- Untracked files are handled via temporary
git add -Nstaging and cleanup (safe, but cannot be completely bypassed if selecting untracked changes) - Very large patches may take longer to generate and validate
Tips
- Use multi-select (Ctrl+Click or Cmd+Click) to select multiple files at once
- The last target worktree is pre-selected in the Quick Pick for convenience
- If a patch fails to apply, examine the Git error message for merge conflicts or other issues