Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Git Patch to WorktreeNew to Visual Studio Code? Get it now.
Git Patch to Worktree

Git Patch to Worktree

Tyler Trebuchon

| (0) | Free
Apply a git patch of selected SCM changes to another worktree or repository without stashing the entire working tree.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Patch to Worktree

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:

  1. git stash
  2. Switch branch
  3. git stash pop
  4. Commit
  5. Stash again
  6. Switch back
  7. Pop again

Just:

  1. Select your files in SCM
  2. Right-click → "Patch to Worktree..."
  3. Pick your target
  4. 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

  1. Open the Source Control view in VS Code
  2. Select one or more files in the "Changes" section
  3. Right-click and choose Patch to Worktree...
  4. Select the target worktree or repository branch from the Quick Pick
  5. 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 -N staging 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
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft