Git Worktree in VS Code
Visual Studio Code is the most popular editor for working with git worktree. Current VS Code releases have built-in support for discovering, creating, opening, and deleting worktrees. Multi-root workspaces and separate editor windows still matter, but worktrees are no longer just an extension-driven workflow in VS Code.
Built-in Git Worktree Support
VS Code added built-in Git worktree support in version 1.103. The Source Control Repositories view can detect linked worktrees for a repository, and the Command Palette plus repository actions let you create, open, and delete worktrees without leaving the editor:
# Built-in VS Code worktree actions
# Command Palette:
# Git: Create Worktree
# Git: Open Worktree in New Window
# Git: Delete Worktree
#
# Source Control > Repositories view:
# open repository actions to create, open, or delete worktreesThe integrated terminal is still useful for advanced flags such as --lock, --reason, or repair, but day-to-day worktree management no longer requires an extension.
Git Worktree VS Code Extensions: Built-in vs GitLens vs Others
Since VS Code now covers the core worktree workflow itself, extensions are optional. Here is how the options compare:
| Feature | VS Code Built-in | GitLens | Third-party Extensions |
|---|---|---|---|
| Create worktrees | Yes (Command Palette) | Yes | Varies |
| List worktrees | Yes | Yes (dedicated panel) | Varies |
| Open in new window | Yes | Yes | Some |
| Delete worktrees | Yes | Yes | Some |
| Branch history / blame | Basic | Advanced (inline blame, graphs) | No |
| Cost | Free | Free (Pro features paid) | Free |
When to Use GitLens
GitLens adds value when you need rich Git context alongside your worktrees: inline blame annotations, commit graphs, comparison views, and a dedicated worktrees panel with more detail than the built-in Source Control view provides. If you already use GitLens for other Git features, its worktree support is a bonus.
Do You Need a Third-Party Worktree Extension?
In most cases, no. Older extensions like "Git Worktrees" were essential before VS Code added built-in support. Now they are best treated as workflow preferences rather than requirements. If a third-party extension offers a specific UI or shortcut you prefer, it is fine to use — but the built-in features handle the standard create/list/open/delete workflow.
Setting Up VS Code Workspaces with Worktrees
A VS Code workspace file lets you save a collection of folders and settings. You can create a workspace that includes multiple worktrees, making it easy to switch between them:
// my-project.code-workspace
{
"folders": [
{
"name": "main",
"path": "./my-project"
},
{
"name": "feature-auth",
"path": "./my-project-feature-auth"
},
{
"name": "bugfix-42",
"path": "./my-project-bugfix-42"
}
],
"settings": {
"git.autoRepositoryDetection": "subFolders"
}
}Save this file alongside your worktree directories (in the parent folder) and open it with File > Open Workspace from File. VS Code will show all worktrees in the Explorer sidebar with their assigned names.
Opening Worktrees in New Windows
The simplest approach is to open each worktree in its own VS Code window. This gives each worktree a fully independent editor with its own terminal, source control panel, and file explorer:
# Create a worktree and open it in a new VS Code window
git worktree add ../feature-login feature/login
code ../feature-login
# Or open in the current window
code -r ../feature-loginYou can also use VS Code's File > Open Folder to navigate to a worktree directory. Each window will show the correct branch in the status bar.
Multi-Root Workspaces
VS Code's multi-root workspace feature lets you add multiple folders (including worktrees) to a single window. This is useful when you want to compare code across branches side by side:
# Add a worktree folder to your current workspace
# Use: File > Add Folder to Workspace...
# Navigate to the worktree directory
# Or from the command line, add to a workspace file:
code --add ../feature-branchConsiderations for multi-root workspaces with worktrees:
- Each root folder gets its own Source Control provider in the sidebar
- The integrated terminal defaults to the most recently focused folder
- Search (
Ctrl+Shift+F) spans all workspace folders by default — use the file filter to limit searches to a specific worktree - Tasks and launch configurations can be scoped to individual folders
Tips and Tricks
Color-Code Your Windows
Use VS Code's workbench.colorCustomizations to assign different title bar colors to each worktree window. Add this to the .vscode/settings.json inside each worktree:
// .vscode/settings.json in your feature worktree
{
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#1e3a5f",
"titleBar.activeForeground": "#ffffff"
}
}Share Extensions Across Worktrees
VS Code extensions are installed globally (per user), not per project. All your worktree windows automatically have access to the same extensions. However, extension settings stored in .vscode/settings.json need to be committed to the repo or copied to each worktree.
Create a Keyboard Shortcut for Worktree Commands
Bind VS Code's built-in Git worktree commands to keyboard shortcuts via File > Preferences > Keyboard Shortcuts. Search for "worktree" to find available commands.
Terminal Profile for Worktree Navigation
Add a shell alias to quickly list and switch between worktrees from VS Code's terminal:
# Add to ~/.bashrc or ~/.zshrc
alias wt='git worktree list'
alias wta='git worktree add'
alias wtr='git worktree remove'
# Quick open a worktree in a new VS Code window
wto() {
local dir=$(git worktree list --porcelain | grep "^worktree" | awk '{print $2}' | fzf)
[ -n "$dir" ] && code "$dir"
}