Git worktrees have existed since 2015, but AI coding agents are driving a sudden surge of interest because agents need to work across multiple branches simultaneously without blocking each other. A worktree lets you check out a second branch into a separate directory on disk while your main working directory stays untouched. No stashing, no context switching, no waiting.

The traditional alternative is a 5-step stash-checkout-branch-fix-pop cycle every time an interrupt hits. With worktrees, you run one command, git worktree add ../hotfix-bug main, and you have a fully independent working directory pointed at a fresh branch. Your editor, your build tools, and your in-progress changes in the original directory are completely undisturbed. The two trees share one .git folder, so objects and refs stay consistent without duplication.

The original article is worth reading in full for the filesystem mechanics: how the .git/worktrees directory tracks each linked tree, what happens when you remove one with git worktree remove, and where the workflow breaks down, specifically around bare repositories and editor configuration. The AI agent use case is also mapped out concretely, which is the real reason this 9-year-old feature is back in the conversation.

[READ ORIGINAL →]