AI Coding Agents Finally Made Me Care About Git Worktrees

Working with Git Worktrees in Magit

AI Coding Agents Finally Made Me Care About Git Worktrees

I ignored git worktrees for a decade, but AI coding agents like Claude Code changed that. They spin up a worktree per task so multiple agents can work on the same repo in parallel. Magit has had worktree support for years, hidden behind Z, and each worktree gets its own status buffer. I share practical tips and note that Jujutsu makes the whole problem mostly go away.

What finally introduced me to worktrees was, of all things, AI coding agents.
  1. prima-facie

    I use grm when I need worktrees, which makes admin a bit easier; https://github.com/hakoerber/git-repo-manager

  2. simonhamp

    Just use copy-on-write clones. They're way more flexible, faster and easier to reason about.

    I don't get spending all this time on tooling that tries to ease working with worktrees when they're just not the right abstraction for the way we're working now.

  3. miggol

    A slight limitation of worktrees is that you can only have a branch checked out once in all of your worktrees. I guess that's just how git works.

    But when I want to checkout a branch that's already checked out in another worktree, Magit just plain refuses. I wish it would offer me to either:

    1. Switch to that worktree instead

    2. Detach head in the other worktree and checkout here

    Would be such an improvement! No excuses though, I love magit and might as well hack this myself. I'm just bad at elisp.

  4. brabel

    As the author, I have been using worktrees due to AI agents. And I love Magit but didn’t know it handles git worktrees so well! Thanks for letting me know, will start using magit to manage my worktrees immediately.

  5. hyfgfh

    Sorry git worktrees are a waste of time

    Just keep multiple copies of the repo

More from this day

2026-09-11