docs/features/worktrees.mdx
Worktrees let you work on multiple branches simultaneously, each in its own folder. This enables Cline to work on tasks in parallel across separate VS Code windows, or lets Cline work independently while you continue coding in your main workspace.
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:
.git directory livesWorktrees solve a common problem: Cline takes over your VS Code window while working on a task. With worktrees, you can:
The fastest way to start using worktrees is the New Worktree Window button on Cline's home screen:
A new VS Code window opens with your worktree, and Cline automatically opens ready to work.
<Tip> The home screen also shows your current branch and worktree path. Click it to open the full Worktrees view. </Tip>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:
<Steps> <Step title="Create a New Worktree"> Click **New Worktree** at the bottom of the view. Enter a branch name and path (defaults are auto-filled). </Step> <Step title="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. </Step> </Steps>Here's how a typical worktree session looks:
<Steps> <Step title="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. </Step> <Step title="Do your work"> Work on your feature or let Cline handle a task. Make commits as you go. </Step> <Step title="Close the worktree window"> When you're done, close the worktree's VS Code window. </Step> <Step title="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. </Step> </Steps>The Worktrees view shows all worktrees for your repository:
.git directory lives (cannot be deleted)Each worktree has two open options:
Either way, Cline automatically opens in the new workspace, ready to start a task.
Click the trash icon on any linked worktree to delete it. A confirmation dialog will show you exactly what will be deleted:
When you're done working in a worktree and ready to merge your changes back to the main branch:
If your branch has conflicts with the main branch, Cline will detect them and show you the conflicting files. You have two options:
When you create a new worktree, it starts with a fresh checkout—no node_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.
.worktreeinclude file in your repository root.gitignore syntax).worktreeinclude and .gitignore are copied automatically.worktreeinclude# Copy node_modules to avoid npm install
node_modules/
# Copy IDE settings
.vscode/
# Copy build cache
.next/
dist/
# Copy environment files (if gitignored)
.env.local
.worktreeinclude FileThe 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.
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:
# In your repository root
ln -s .gitignore .worktreeinclude
Now whenever you update your .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.
Worktrees are not available in certain workspace configurations:
The Worktrees view will display a message explaining the limitation if either of these applies to your workspace.
Cline CLI's --cwd flag unlocks powerful command-line worktree workflows:
--config for different models per worktree, or --thinking for deep analysisExample:
# Run parallel tasks in different worktrees
cline --cwd ~/worktree-a -y "refactor authentication" &
cline --cwd ~/worktree-b -y "add unit tests" &
wait
For complete CLI worktree patterns and examples, see Worktree Workflows.
Worktrees unlock true parallel development with Cline. Create a worktree, open it in a new window, and let Cline work independently while you continue coding!