GitWorktree.org logoGitWorktree.org

Git Worktree: The Complete Guide

git worktree lets you check out multiple branches of the same repository into separate directories at the same time. Instead of stashing changes, cloning the repo, or constantly switching branches, you create lightweight linked working trees that share a single .git directory. This means you can review a pull request in one worktree, fix a hotfix in another, and keep your feature branch untouched — all without losing context.

This site is a comprehensive, community-driven reference for everything related to git worktree — from basic commands to advanced workflows with AI coding agents and IDE integrations.

Quick Start: Your First Worktree

Creating a new worktree takes a single command. From any existing repository, run:

Basic git worktree commands
# Create a worktree for an existing branch
git worktree add ../hotfix-login hotfix/login

# Create a worktree with a new branch
git worktree add -b feature/search ../search-feature main

# List all active worktrees
git worktree list

Each worktree is a full working directory backed by the same repository. Changes committed in any worktree are immediately visible to all others. When you are done, clean up with git worktree remove.

Tutorial

Step-by-step guides for every git worktree subcommand, from creating your first worktree to advanced management.

Guides & Best Practices

Production-tested patterns and workflows for using git worktree effectively in real projects.

Comparisons

Understand when to use git worktree versus other Git workflows, with side-by-side breakdowns.

AI Coding Tools & Worktrees

Git worktree is the foundation for running multiple AI coding agents in parallel. Learn how to pair worktrees with the latest AI development tools.

IDE & Editor Integration

How to use git worktree in your editor of choice, with setup guides and recommended extensions.

Troubleshooting

Solutions to the most common git worktree errors and edge cases, with copy-paste fixes.

Why Use Git Worktree?

Zero-cost context switching

Each worktree is a fully independent working directory. Switch tasks by changing directories, not branches. Your build cache, open files, and IDE state remain exactly where you left them.

Disk-efficient parallelism

Unlike cloning, worktrees share the same Git object store. A second worktree adds only the working directory files — not another copy of your entire history.

Built for code review

Check out a pull request in a separate worktree, run tests, and review the code without touching your current work. Merge or close the PR, remove the worktree, and carry on.

AI agent isolation

Run multiple AI coding agents (Claude Code, Codex, Cursor) on the same repository in parallel, each in its own worktree, without merge conflicts or file contention.

Additional Resources