Git worktrees are gaining popularity lately, despite being around for more than a decade. Agentic AI has resulted in simultaneous threads of ressearch, exploration and prototyping. Worktrees provide the exact kind of sandbox that such workflows require.
I started using worktrees around a year ago when I was provided access to two different modern IDEs with agentic capabilities and I wanted an efficient way to evaluate both to identify the winner for my team. I learned a few ways to use them in a way that works for me.
Golden Trunk Directory: I don’t edit most files in this directory at all. It always points to the trunk and acts as the source of truth from which all worktree workspaces originate. The only files I touch on here are environment configuration files, that are usually .gitignore-ed. This folder is meant to help me understand the current state of the codebase.
Maintain Hygiene: I am one of those engineers who audibly gasp when I see more active branches in a repository than there are engineers on the team (more on why I think so in another post!). As with branches, there should be utmost care while maintaining worktrees to avoid sprawl. Give them meaningful names, do not let them live beyond their use, and ensure you do not have more worktrees than you need at the current point in time.
Persist Any New Learning to Trunk: This is my favourite part of using worktrees, and following the previous point rather religiously. When I am satisfied with the outcomes in a workspace, I like to take a deep look at the artifacts and figure out the ones I need to bring back to the trunk so that the team can benefit from it. Agentic development leaves breadcrumbs with chat sessions and files that contain insights into the deeper conversations. This practice helps me persist them as a team practice that we can deliberate on in a code review, if/when required.
A Worktree for Every PR Review: As a senior individual contributor, I have to review several pull requests every week, and not every one of them can be done on the web UI. I pull them down to a new worktree so that I can review them in isolation. This is great because I can keep notes under each of these without having to remember which review the notes belong to.
Git worktrees have been around for over a decade, but it took agentic AI to make them indispensable. The practices above are simply how I’ve adapted an old tool to a new pace of work. They’ve made that pace a lot more manageable. If you’re feeling the strain of juggling multiple parallel threads of exploration, it might be worth giving worktrees a real look.
Leave a comment