@github: Git worktrees have been around since 2015, but they've made a resurgence. @cassidoo explains what they are and why AI-e…
Summary
Git worktrees, a feature available since 2015, are gaining popularity as AI-era parallel work makes them essential. This article explains what worktrees are, how they differ from branches, and why they reduce context-switching overhead for developers.
View Cached Full Text
Cached at: 07/05/26, 08:35 PM
Git worktrees have been around since 2015, but they’ve made a resurgence. @cassidoo explains what they are and why AI-era parallel work makes them feel essential. https://github.blog/ai-and-ml/github-copilot/what-are-git-worktrees-and-why-should-i-use-them/?utm_source=x-git-worktrees&utm_medium=social&utm_campaign=github-copilot-app-ga-2026…
What are git worktrees, and why should I use them?
Source: https://github.blog/ai-and-ml/github-copilot/what-are-git-worktrees-and-why-should-i-use-them/?utm_source=x-git-worktrees&utm_medium=social&utm_campaign=github-copilot-app-ga-2026 It seems like the latest hotness in git these days is the concept of worktrees. Which… is kind of funny because they’ve been around since 2015.
But, nevertheless, they are cool, and you might be wondering why you’d use them, how they differ from branches, and why they are suddenly so popular.
Let’s talk about it!
Context switching with branches and stashing
Let’s say you lived in a worktree-less world, and were working on a ticket, and suddenly an urgent bug came to you and you had to switch contexts.
First, you might stash your work:
git stash "wip feature login"
Then you’d switch to your main branch and update:
git checkout main
git pull origin main
Then make a bugfix branch:
git checkout -b hotfix-bug
Then you’d fix everything, commit, and push the branch:
git add .
git commit -m "fix broken submit button"
git push origin hotfix-bug
Then after merging a pull request, you might return back to your computer and pull main and remove the bug branch:
git checkout main
git pull origin main
git branch -d hotfix-bug
And then you could go back to the feature you were working on:
git checkout feature-login
git stash pop
Phew. Where were we?
The mental overhead of switching around, reloading files, reinstallingnode\_modulesbased on whatever changed, and so on, is a lot. The context switching burden is heavy.
Now, this is a basic example, but sometimes developers would work around this kind of chaos with doing some more complicatedgit stashcommands, or even multiple clones of the same repo (I’m guilty of that one).
Until… worktrees!
Context switching with worktrees
With worktrees, you never leave your branch and you never stash, and your editor context for your original feature stays untouched.
git worktree add ../hotfix-workspace -b hotfix-bug main
This instantly creates a sibling folder calledhotfix\-workspace, and bases it on main, and checks out a new branch calledhotfix\-bug.
Now you can open that folder in a new editor window (orcdinto it) and fix the bug. Your original editor window stays exactly as you left it.
cd ../hotfix-workspace
# ...fix fix fix...
git add .
git commit -m "fix broken submit button"
git push origin hotfix-bug
You merge the pull request online just like before, and once it’s merged, you can simply delete the temporary folder.
cd ../main-project
git worktree remove ../hotfix-workspace
This is so much smoother! Worktrees can go beyond the git command line, too. For example,VS Code has full worktree support built in. You have options! And no matter where you work, worktrees give you zero risk of stash conflicts, there’s no editor disruption, and you can truly work in parallel.
So… why now?
For a really long time, worktrees were relatively unknown. Most developers had never heard of them, because either Git GUIs didn’t support them (or treated them as second-class citizens), or because they just usually followed the known pattern of feature branch, then work, then PR, then merge, then repeat.
Now, our work as developers has changed. AI has made us work in parallel more than we ever have before in the history of software development. Developers run so many sessions in parallel, and “code review culture” is growing beyond “code writing culture.”
Agents and humans can do more in parallel with worktrees. It’s the default mode for theGitHub Copilot app, and for many other modern tools.
What’s the catch?
Worktrees do solve a whole lot of issues, but there’s definitely some things to watch out for.
- Dependency bloat: each worktree folder requires its own copy of your project dependencies. If you’re running
npm installorpip installacross multiple of them, your computer might get very full, very quickly. - Folder management: you have to delete the worktree folders, to avoid cluttering your parent directory over time. Apps like the GitHub Copilot app do often handle this for you, but it’s still something you might have to do yourself if you’re operating in the terminal yourself.
- Global
\.gitignorerequirements: if you create worktree folders inside your main repo directory, you have to manually add them to\.gitignoreto not accidentally track them. Youcanmake these worktrees outside of your main repo (and many apps do that by default), but it’s worth noting. - One branch limits: Git prevents you from checking out the exact same branch in two different worktrees at the same time to prevent data corruption.
How do I use worktrees in the GitHub Copilot app?
Great question! What’s awesome is they “just work” out of the box. When you open the app, there’s a dropdown that asks you where you want to run your new session on the home screen. The default is a new worktree.
Then, once you kick off a new session, you can click the session name at the top of the app, and you’ll see the (fun!) generated name of your worktree, as well as the path where it’s located, the project that worktree is for, and details about the changes that you’ve made.
Easy peasy lemon squeezy!
Should I use worktrees?
I will give you the most senior developer answer I can: It depends! You might prefer working in one way or another. You might not do as much work in parallel and like the mental model of branches and stashing. You might only do worktrees from now on. You might want to do both!
The world’s your oyster, and you can try them all in theGitHub Copilot apptoday.
Written by
Cassidy is senior director for developer advocacy here at GitHub. She enjoys building software, advising startups, and teaching developers how to build better. She has a weekly newsletter at cassidoo.co/newsletter where you can get her updates, practice coding problems, and a joke in your inbox!
Related posts
Highlights from Git 2.55
The open source Git project just released Git 2.55. Here is GitHub’s look at some of the most interesting features and changes introduced since last time.
Explore more from GitHub
Docs
Everything you need to master GitHub, all in one place.
GitHub
Build what’s next on GitHub, the place for anyone from anywhere to build anything.
Customer stories
Meet the companies and engineering teams that build with GitHub.
GitHub Universe 2026
Join us October 28-29 in San Francisco or online for GitHub Universe, our flagship developer event uniting people, agents, and the world’s code.
Similar Articles
@mogician301: https://x.com/mogician301/status/2071841989751112147
The article introduces the advantages of git worktree for parallel multi-task development in the AI era, and how the cc-launch tool developed by the author addresses worktree usage pain points through automatic initialization and unified management, improving development efficiency.
Git platform built for agentic era
A new git platform designed for the agentic era, likely targeting AI-driven development workflows.
GitLab says Git is being reengineered for "machine scale." Was the idea of "Git for AI agents" ahead of its time?
GitLab's statement about reengineering Git for machine scale and AI agents as first-class participants in software development prompts reflection on whether the 'Git for AI agents' concept was ahead of its time.
Rift: Better Alternative to Git Worktrees
Rift is a command-line tool that provides a better alternative to Git worktrees, offering copy-on-write snapshots for fast workspace creation on Linux with btrfs and macOS with APFS.
@maxk4tz: the worktree switching is insanely good @zeddotdev finally can say goodbye to slow electron shit
Developer praises a tool for fast git worktree switching as a replacement for slow Electron-based Git clients.