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

Git Worktree Script Runner

InshomePgup

|
1 install
| (0) | Free
Auto-discover Git worktrees, detect npm/pnpm/yarn/bun/deno, and run package.json scripts in dedicated terminals.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Git Worktree Script Runner

VS Code Marketplace Open VSX License: MIT

English | 简体中文

Visually and quickly run each branch's project across your Git worktrees.

Scope: Specifically for projects with a package.json (JavaScript / TypeScript / Node.js / Bun / Deno — supporting npm, pnpm, yarn, bun, and deno). Projects in other languages without package.json are not supported.

Quick Start

  1. Install from VS Code Marketplace, Open VSX (Cursor / Windsurf / VSCodium / Trae), or code --install-extension inshomepgup.vscode-worktree-runner.
  2. Reload Window — press Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (macOS), then run Developer: Reload Window.
  3. Run multiple projects in your workspace — open the Worktree Runner sidebar and click ▶ to run, restart, or stop scripts across every worktree (dedicated named terminals, auto package manager detection, and 1-click install if node_modules is missing).

Keep .code-workspace in Sync with Worktrees

If you open multiple worktrees in a .code-workspace file, you can keep its folders list aligned with git worktree list:

  • One-click manual sync: click the Sync button in the Worktrees & Scripts view title bar or run Worktree Runner: Sync .code-workspace Folders from the Command Palette.
  • Automatic sync (optional): enable "worktreeRunner.autoSyncCodeWorkspace": true (default false) to automatically add new worktrees, update branch names, and remove deleted managed worktrees from the active .code-workspace whenever your worktrees change.
  • Non-destructive JSONC edits: comments, formatting, tasks, settings, and unrelated external folders are always preserved. Control whether the main repo folder is included via worktreeRunner.workspaceSyncIncludeMain (default true).
{
  "worktreeRunner.autoSyncCodeWorkspace": true,
  "worktreeRunner.workspaceSyncIncludeMain": true
}

Vite Multi-Worktree Port Example

For example, if your main repo uses port 5173, other worktrees can auto-assign ports with the following config.

Keep the main repo on 5173 and give each linked worktree a stable, conflict-free port (vite.config.ts):

import fs from 'node:fs';
import path from 'node:path';
import { defineConfig } from 'vite';

function getWorktreePort(basePort = 5173, range = 500): number {
  if (process.env.PORT) return Number(process.env.PORT);

  // Main repo has a `.git` directory (fixed 5173); linked worktrees have a `.git` file
  try {
    if (fs.statSync(path.join(process.cwd(), '.git')).isDirectory()) {
      return basePort;
    }
  } catch {
    // Fall back to path hashing (e.g. monorepo subdirectories)
  }

  let hash = 0;
  for (const ch of process.cwd()) {
    hash = (hash * 31 + ch.charCodeAt(0)) >>> 0;
  }
  return basePort + 1 + (hash % range);
}

export default defineConfig({
  server: {
    port: getWorktreePort(),
    strictPort: false,
  },
});

Configuration & Reference · Changelog · Contributing · MIT License

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft