What is a git worktree?
The plain-English definition, why you'd want one, and when not to use one.
- A git worktree is a second working directory for a repo you already have: own files, own branch, same
.git. - Benefit: work on two branches at once with no stash, no checkout, no rebuild.
- Running several worktrees, one per AI agent, gets hard to track from a terminal. teebe is a free macOS app that shows them all, live, in one window.
A git worktree is an extra working directory attached to a repository you
already have. It gets its own checked-out files, branch and index, but shares the same
.git history, branches, stashes and remotes as your main checkout. Two folders,
two branches, one repository, and you work in both without ever running
git checkout. Git has had git worktree since 2.5 in 2015; AI coding
agents are what finally made it an everyday tool.
The problem worktrees solve
A normal repository has one working directory, so only one branch can be checked out at a
time. Switching rewrites your files: uncommitted work gets stashed or committed half-finished,
and node_modules, build caches and dev servers get rebuilt or restarted. A
worktree removes the one-directory limit. Your feature branch stays put, and the hotfix, the
pull request you're reviewing, or the agent you just started gets a directory of its own.
How it works
git worktree add creates a directory and checks a branch out into it. A small
.git file there points back to the main repository, so history and refs are
shared and only the working files are duplicated. That makes a worktree far cheaper than a
second clone, with nothing to re-fetch. One rule: a branch can be checked out in only one
worktree at a time. More in git worktree vs branch,
and every command in the git worktree cheat sheet.
Not the right tool for: a two-minute interruption on your current branch, where
git stash is faster, or a fully separate copy with its own remote, where you
want a second git clone.
Benefits of git worktrees
- No more branch switching. In-progress work never moves, so there's nothing to stash and no messy
stash poplater. - Each branch keeps its own build. Dependencies and caches live per directory. Changing context is
cd, not a rebuild. - Run things side by side. Tests on two branches, a dev server on main next to a feature, a pull request checked out for review.
- Cheaper than a clone. One object store, one set of remotes, and a commit in any worktree is visible in all of them instantly.
- One worktree per AI agent. Claude Code, Codex and Cursor isolate parallel sessions in worktrees so agents can't overwrite each other's files, or yours.
Why AI coding agents made worktrees mainstream
For a decade, worktrees were a git feature most developers had never touched. A person works on one thing at a time, so one working directory was rarely the bottleneck. Coding agents changed that almost overnight. Once a Claude Code, Codex or Cursor session can take a task and run with it for twenty minutes, the obvious next move is to start a second one, and a third. Two agents editing the same checkout overwrite each other, and both trample whatever you were doing. Give each one its own worktree and the problem disappears: every agent gets its own branch, its own files and its own build, and you review each result like any other pull request. That's why all three tools now offer a worktree per session, and why a git feature from 2015 suddenly matters to everyone. Details for each in our Claude Code, Codex and Cursor guides.
The side effect is several directories on disk, each mid-change, with no easy way to see them together. teebe was built for exactly this: every worktree of every repo in one native macOS window, files badged the instant an agent touches them, and any diff one keypress away. Three sessions, no three terminal tabs. Free and open source; here's how it compares to every other worktree GUI for Mac.
Frequently asked questions
What is a git worktree in simple terms?
An extra working directory for a repository you already have, with its own files and branch
but the same .git history. Two folders, two branches, one repository, no
switching.
What is the benefit of git worktrees?
You stop switching branches. Fix a bug on main, review a pull request, or run an AI coding agent on another branch while your in-progress work stays where it is. No stash, no rebuild, no half-done commits.
Is a git worktree the same as a clone?
No. A clone copies the whole object store and has its own remotes to keep in sync. A worktree
shares one .git with the main checkout, so it costs only the working files and
commits made in one worktree show up in all the others instantly.
How do I see all my git worktrees?
Run git worktree list in any checkout of the repository. On macOS,
teebe shows every worktree of every repo in one window, with a live file tree
and inline diffs, and picks up worktrees the moment they're created from the terminal or by an
AI agent.
curl -fsSL https://teebe.io/install.sh | bash
Free · open source · macOS 14+. Back to teebe.io →