Git Worktrees Clearly Explained (and how to use them)
David Ondrej
November 25, 2026
David Ondrej
This video is the clearest explanation of Git work trees on the internet and how they make your AI agents a lot more powerful. So, what even are Git work trees? I would say this is one of the most essential concepts to understand in 2026, if you're building software, yet most people do not understand it or don't know anything about it. And it's especially important to know if you're using multiple AI agents at the same time, such as ClaudeCode, Codex, Antigravity, or any other agent. So, in this video, I'm going to explain what Git work trees are, how they work, and why everyone is going crazy over them. So here's the issue with not using Git work trees. Let's say you're doing some work on a feature, and then there's a critical bug report, and you need to fix this bug, right? Well, what you need to do normally, you need to stash your progress on the feature, then you need to switch to the main branch where the bug is, you need to fix the bug, then you need to switch back, pop the stash, and just like that, you lost a bunch of time context switching and having to stop what you were doing to fix another thing, because you're not using Git WorkTrees. So here is the core idea. Git WorkTrees on the surface, when you hear it for the first time, they sound complicated, okay? Sounds like a super deep programming term, but the idea behind Git WorkTrees is actually very simple and very elegant. A new WorkTree is basically a copy of your project folder, but with the same Git history, right? So it's literally a different folder, but with the same commits that led up to its creation. So you can think of it as opening the same Google Doc in two different tabs, but each is a different version of the same Google Doc, right? The changes and the creation were the same, but now they're separate Google Documents, so you can edit them in a different way. With WorkTrees, you can have multiple things happening at the same time, right? In the first WorkTree, you can be doing a new feature for authentication. In the second WorkTree, you can be hot fixing a bug. In the third one, you can be reviewing a PR. And as you might have guessed, this is especially important with AI agents, because if you're not running multiple AI agents in parallel, you're missing out on a lot of productivity. But David, why now? Why are Git WorkTrees blowing up right now when they were created 11 years ago in 2015? And the answer is AI agents. Git WorkTrees have never been so essential, right? Look at this. Even in the half of 2025, Git WorkTrees were like okay-ish, but like 15% as popular as they are right now. So I'm not joking. If you are not using Git WorkTrees in 2026, you really are falling behind. Now real quick, if you're enjoying this video and you wanna see more practical tutorials like this one, make sure to subscribe. In the YouTube studio, I can only see that 25% of you watching are subscribed, which means three out of four people are not. So if you want to see more high-quality AI content appear in your YouTube recommended, go below the video and click the subscribe button. It's greatly appreciated. Thank you very much. Now AI agents absolutely love Git WorkTrees. First of all, this is what makes true parallel execution possible, right? There's no more cross-fighting because in the past, you had agent A doing stuff, agent B, and even if they work on different features, maybe they change the same file, and then it's confusion, like why is this file changed? It was different when I read it the last time. I'm gonna make these changes and then messes up with the other agent. A lot of complications like that, but with Git WorkTrees, this is no longer an issue. Also, you can avoid the problem of context pollution. This is the issue of you switching a branch while a different agent is working, so it's polluted with context that doesn't exist. And context pollution is a real issue that is completely solved with Git WorkTrees. So by fully embracing the concept of Git WorkTrees, you can finally become a real agentic conductor, while others are still trying to be VibeCoders. And don't worry, I'll show you all of this, how to do it, and how to actually use it inside of Cloud Code later in the video. So here's what it looks like in practice when working with AI agents using WorkTrees. Each agent gets their own WorkTree, allowing it to cook. You know, nothing is preventing it, nothing is clashing with it. And imagine, like, all of us have this memory of having only one computer in the household, right? You have to share the same device with others.
Read the other 20 minutes of this episode here.
$15 gets you this episode and 99 more. Credits never expire. After checkout, one link brings you back here to read it.
Not what you expected? Full refund within 14 days.
Thousands of transcripts fetched by people building searchable podcast archives
Fetch transcripts with code
The same credits work from a script or an AI agent. The demo key returns a sample episode in full, no card needed:
curl -H "x-api-key: pt_demo" \
https://spoken.md/transcripts/1000651996090Markdown with the speakers named, for your notes, your knowledge base, or anything that makes HTTP calls.
From $0.10 per transcript. No subscription. Credits never expire. Prices exclude VAT, added at checkout for EU customers. Not what you expected? Email us within 14 days with 20 or fewer credits used and we refund the pack in full.
Using your own key:
curl -H "x-api-key: YOUR_KEY" \
https://spoken.md/transcripts/1000803891269