Git Worktree Refresh helps VS Code notice Git worktrees that were created outside VS Code. It exists to address microsoft/vscode#320749.
When a repository is open, the extension watches the repository's common Git directory for worktree metadata changes. When that metadata changes, it rescans known Git worktrees and asks VS Code's built-in Git extension to open any worktree repositories that are not already registered in Source Control.
- Watches
.git/worktreesmetadata for open repositories. - Opens newly discovered worktrees through VS Code's built-in Git API.
- Provides a manual
Git Worktree Refresh: Rescan Worktreescommand. - Logs decisions and failures to the
Git Worktree Refreshoutput channel.
- VS Code with the built-in Git extension enabled.
- Git available on
PATH. - Local repositories must be trusted by VS Code workspace trust before VS Code can open them.
This extension contributes the following settings:
gitWorktreeRefresh.autoRefresh: Enable or disable automatic metadata watching. Defaults totrue.gitWorktreeRefresh.debounceMs: Delay before rescanning after metadata changes. Defaults to750.gitWorktreeRefresh.showNotifications: Show notifications for refresh events and failures. Defaults tofalse.
Install dependencies:
pnpm installCompile:
pnpm run compilePackage a local VSIX:
pnpm dlx @vscode/vsce packageInstall the generated .vsix from VS Code:
code --install-extension git-worktree-refresh-0.0.1.vsixReload VS Code after installing.
-
Open a Git repository in VS Code.
-
Confirm Source Control is enabled and the repository appears.
-
From an external terminal, create a worktree:
git worktree add ../repo-feature-branch feature-branch
-
Open the Source Control Repositories list.
-
Confirm the new worktree appears without reloading the window.
-
If it does not appear, run
Git Worktree Refresh: Rescan Worktrees. -
Check
View: Toggle Output->Git Worktree Refreshfor diagnostics.
- The extension focuses on newly discovered worktrees. Removing worktrees may still rely on VS Code's built-in Git extension to dispose stale repositories.
- The extension does not edit
.code-workspacefiles or add workspace folders. - If VS Code rejects a repository because of workspace trust or Git safe-directory rules, this extension logs the failure but does not bypass that protection.
MIT