·2 min read

Git worktrees changed everything

I started using git worktrees earlier this year and can't go back.

The idea is simple: instead of switching branches (which swaps your entire working directory), you check out each branch into its own directory. All share the same git history.

git worktree add ../project-feature-auth feature/auth
git worktree add ../project-bugfix-login bugfix/login

Now I have three directories open simultaneously. Main in one terminal, feature branch in another, hotfix in a third. I never stash anymore, and I always know which branch I'm on.

This matters more with AI-assisted development than it did before. Each worktree gives Claude Code a clean, isolated context. When I'm working on authentication in one worktree, Claude doesn't see the half-finished refactor in another. The context stays focused, and as I've written before, context is everything.

The workflow: new task, new worktree. Finish the work, merge, delete the worktree. Need to hotfix production? Worktree from main, fix it, merge, done. The feature branch is still running in its own terminal, untouched.

Context-switching used to cost me thirty minutes of re-orientation. With worktrees, it costs the time it takes to click a terminal tab.

If you're using Claude Code and not using worktrees, you're mixing contexts that should be separate. Try it for a week.