
What Are Git Worktrees?
A Git worktree is a linked copy of your repository in a separate folder, checked out to a specific branch. All worktrees share the same Git history and.git directory, but each has its own working directory with different code checked out.
Key concepts:
- Main worktree: Your original repository folder where the
.gitdirectory lives - Linked worktrees: Additional folders you create, each checked out to a different branch
- Shared history: All worktrees share commits, branches, and Git configuration
Why Use Worktrees with Cline?
Worktrees solve a common problem: Cline takes over your VS Code window while working on a task. With worktrees, you can:- Run Cline in parallel - Have Cline work on multiple tasks simultaneously, each in its own worktree and VS Code window
- Keep working while Cline works - Let Cline handle a task in a separate worktree while you continue coding in your main workspace
- Isolate experimental changes - Test risky changes in a worktree without affecting your main branch
- Quick context switching - Jump between features without stashing or committing incomplete work
Getting Started
Quick Launch (Recommended)
The fastest way to start using worktrees is the New Worktree Window button on Cline’s home screen:- Click New Worktree Window on the home screen
- Enter a branch name and folder path (defaults are auto-filled)
- Click Create & Open
Full Worktrees View
For more control, open the full Worktrees view by clicking the Worktrees button in the Cline sidebar header, or by clicking your current branch info on the home screen:1
Create a New Worktree
Click New Worktree at the bottom of the view. Enter a branch name and path (defaults are auto-filled).
2
Open in New Window
Once created, click the Open in new window button to open the worktree in a separate VS Code window. Cline will automatically open in the new window.
Typical Workflow
Here’s how a typical worktree session looks:1
Create a new worktree
Click New Worktree Window on the home screen or use the Worktrees view. A new VS Code window opens with Cline ready to go.
2
Do your work
Work on your feature or let Cline handle a task. Make commits as you go.
3
Close the worktree window
When you’re done, close the worktree’s VS Code window.
4
Merge from your primary worktree
Back in your main VS Code window, open the Worktrees view and click the merge button on the worktree you just worked in. This merges the branch and optionally deletes the worktree.
Managing Worktrees
Viewing Worktrees
The Worktrees view shows all worktrees for your repository:- Current: The worktree you’re currently in (highlighted)
- Main: The primary worktree where your
.gitdirectory lives (cannot be deleted) - Locked: Worktrees that are locked to prevent accidental deletion
Opening Worktrees
Each worktree has two open options:- Open in current window: Replace your current workspace with the worktree
- Open in new window: Open the worktree in a separate VS Code window (recommended for parallel Cline sessions)
Deleting Worktrees
Click the trash icon on any linked worktree to delete it. A confirmation dialog will show you exactly what will be deleted:- The branch itself
- All project files in the worktree folder
You cannot delete the main worktree. It’s the primary repository where your
.git directory lives.Merging Worktrees
When you’re done working in a worktree and ready to merge your changes back to the main branch:- Click the merge icon (git merge symbol) on any linked worktree
- Review the merge details in the confirmation modal
- Choose whether to delete the worktree after merging
- Click Merge

Handling Merge Conflicts
If your branch has conflicts with the main branch, Cline will detect them and show you the conflicting files. You have two options:- Ask Cline to Resolve & Merge - Creates a new Cline task with a prompt asking Cline to resolve the conflicts, complete the merge, and clean up the worktree
- Resolve Manually - Close the modal and resolve conflicts yourself using your preferred Git tools
.worktreeinclude: Automatic File Copying
When you create a new worktree, it starts with a fresh checkout—nonode_modules, no build artifacts, no IDE settings. This means you’d normally need to run npm install or similar setup commands.
The .worktreeinclude file solves this by automatically copying specified files to new worktrees.
How It Works
- Create a
.worktreeincludefile in your repository root - Add glob patterns for files you want copied (using
.gitignoresyntax) - When Cline creates a new worktree, files matching both
.worktreeincludeand.gitignoreare copied automatically
Only files that are both matched by
.worktreeinclude AND listed in .gitignore are copied. This prevents accidentally duplicating tracked files.Example .worktreeinclude
Creating a .worktreeinclude File
The Worktrees view will show a tip if you don’t have a .worktreeinclude file. If you have a .gitignore, you can click Create from .gitignore to create one pre-filled with your gitignore contents. Then edit it to keep only the patterns you want copied.
Pro Tip: Symlink to .gitignore
Since.gitignore usually contains most of the files you’d want copied to new worktrees (dependencies, environment files, build caches, etc.), you can create a symlink so they stay in sync automatically:
.gitignore, your .worktreeinclude will have the same patterns. This is especially useful for projects where gitignored files are exactly what you want copied—no need to maintain two separate files.
If you need different patterns than your
.gitignore, create a regular .worktreeinclude file instead of a symlink.Best Practices
For Parallel Cline Sessions
For Parallel Cline Sessions
- Create purpose-specific worktrees - Name branches clearly (e.g.,
cline/refactor-auth,cline/add-tests) - Open in new windows - Always use “Open in new window” for true parallelism
- Use .worktreeinclude - Set up automatic file copying to reduce setup time
For Solo Development
For Solo Development
- Keep your main branch clean - Use worktrees for experimental or risky changes
- Quick feature switches - Instead of stashing, create a worktree for interruptions
- Review in isolation - Create worktrees to review PRs without disrupting your work
Worktree Hygiene
Worktree Hygiene
- Delete unused worktrees - Remove worktrees when their branches are merged
- Use meaningful names - Branch names should indicate the worktree’s purpose
- Check for stale worktrees - Periodically review and clean up old worktrees
Limitations
Worktrees are not available in certain workspace configurations:- Multi-root workspaces: If you have multiple folders open in VS Code, worktrees are disabled. Open a single repository folder instead.
- Subfolder of a repository: If you’ve opened a subfolder within a Git repository (not the root), worktrees are disabled. Open the repository root folder instead.
Troubleshooting
Branch already exists error
Branch already exists error
Git doesn’t allow the same branch to be checked out in multiple worktrees. Either:
- Use a different branch name
- Delete the existing worktree using that branch
Worktree folder already exists
Worktree folder already exists
The path you specified already contains files. Choose a different path or delete the existing folder first.
Can't delete worktree
Can't delete worktree
If a worktree is locked, you’ll need to unlock it first using
git worktree unlock <path> in the terminal. If the worktree has uncommitted changes, you may need to use force delete..worktreeinclude files not copying
.worktreeinclude files not copying
Make sure the files you want copied are:
- Listed in your
.worktreeincludefile - Also listed in your
.gitignore(only gitignored files are copied) - Actually exist in your current worktree
Technical Details
How Worktrees Work Internally
How Worktrees Work Internally
- Worktrees are a native Git feature (
git worktreecommand) - All worktrees share the same
.gitdirectory and object database - Each worktree has its own index, working directory, and HEAD
- Worktree list is stored in
.git/worktrees/
Storage Considerations
Storage Considerations
- Each worktree contains a full checkout of the repository
.worktreeincludecan significantly increase worktree size (e.g., copyingnode_modules)- Consider your disk space when creating many worktrees
Relationship with Checkpoints
Relationship with Checkpoints
Worktrees are separate from Cline’s checkpoint system. Each worktree has its own checkpoint history. Checkpoints track changes within a single worktree, while worktrees let you work across multiple branches simultaneously.

