brands, 5 Seconds, that's all you get.

Git Worktrees

Eliminate Context Switching and Master Parallel Development

By Jared Lyvers, ldnddev — February 28, 2026

I used to treat Git branch switching as a necessary part of the job—stash my changes, checkout another branch, fix the urgent issue, switch back, pop the stash, and then spend precious minutes rebuilding my train of thought. It felt normal. It wasn’t efficient.

If this cycle sounds familiar, you’re in good company. For years I accepted it as “just how Git works.” Then I discovered Git worktrees, and my entire approach to parallel development changed for the better. If you’re still relying on constant stashing and checkout commands, a simpler, more focused workflow is waiting.

The Real Cost of Traditional Branch Switching

Here’s the pattern many of us know too well:

  1. Deep in a feature branch with complex logic in progress
  2. Critical bug reported on main
  3. git stash
  4. git checkout main
  5. Fix, commit, push
  6. git checkout feature-branch
  7. git stash pop
  8. Rebuild context from scratch

Each switch carries a heavy mental tax. Context switching is one of the biggest productivity killers in software development, breaking flow state and increasing mistakes. Git has offered a cleaner solution for years—most teams simply haven’t adopted it.

What Git Worktrees Actually Are

Git worktrees let you check out multiple branches into separate directories at the same time. Every worktree links to the same repository and shares a single .git object database. You get independent working directories without duplicating history or objects.

Think of it as giving each task its own clean workspace while still drawing from the same central resource library. No more clearing the table every time you need to work on something else.

Getting Started in Minutes

The commands are refreshingly simple:

# Create a worktree from an existing branch
                git worktree add ../my-project-hotfix hotfix-branch

                # Create a new branch and worktree in one step
                git worktree add -b feature-auth ../my-project-auth

                # List all worktrees
                git worktree list

                # Remove a worktree when finished
                git worktree remove ../my-project-hotfix
                

Each directory becomes a fully functional copy of the project on its chosen branch. Open separate IDE windows, run tests in one while developing in another—everything stays exactly where you left it.

Tangible Benefits You’ll Notice Immediately

Zero context-switching overhead
Need to handle a production issue? cd to your main worktree, fix it, push, then cd back. Your feature worktree remains untouched and ready.

IDE windows become branch-specific
I keep one VS Code instance for maintenance and hotfixes, another for deep feature work. Tabs, terminals, and open files stay perfectly scoped—no more mental juggling.

Code reviews that actually work
Check out a colleague’s PR in its own worktree, run the site locally, test thoroughly, and provide meaningful feedback—without disturbing your own progress.

git worktree add ../my-project-pr-123 pr-branch-name
                cd ../my-project-pr-123
                # Review and test like you’re working on it yourself
                

Stash becomes nearly obsolete
Worktrees handle the majority of scenarios where I once reached for git stash. The result is cleaner history and far fewer cryptic midnight stash messages.

A Reliable Daily Structure

My projects are organized like this:

~/Projects/
                  my-project/              # Primary repo (usually on main)
                  my-project-feature-ui/   # Long-running feature work
                  my-project-hotfix/       # Temporary urgent fixes
                  my-project-reviews/      # Reusable for PRs
                

Handy aliases I added to .gitconfig:

[alias]
                  wt = worktree
                  wta = "!f() { git worktree add -b \"$1\" \"../$(basename $(pwd))-$1\"; }; f"
                  wtl = worktree list
                  wtr = worktree remove
                

New feature? Just run git wta feature-new-thing.

Worktrees + AI Coding Tools

When you’re iterating with AI assistants, worktrees become even more valuable. Keep one workspace for AI-generated experiments, another for testing and integration, and a clean one for comparisons. Context stays clear and the AI never gets confused by mixed changes.

Disk Space Reality Check

Worktrees do not duplicate the entire repository. They share the same object database; only the working files for each branch take extra space. For typical web projects (including Drupal and WordPress sites we build), the overhead is negligible compared with the time and focus you gain.

When Worktrees May Not Be the Best Fit

They shine when you frequently switch contexts, maintain multiple long-running branches, or perform hands-on code reviews. They’re less critical if you truly work on one branch at a time or face extreme storage constraints.

The Bottom Line

Git worktrees have been available since Git 2.5, yet many developers still default to the old stash-and-switch routine. Once you experience the difference, there’s no going back.

At ldnddev, we rely on worktrees (and other modern practices) to keep our custom website, Drupal, and WordPress projects moving forward efficiently—delivering clean code, faster iterations, and fewer surprises for our clients.

Ready to simplify your Git life? Try worktrees on your next project. Your focus and velocity will thank you.

What productivity practice has made the biggest difference in your workflow lately? I’d love to hear it.

Until next time, Jared Lyvers

Brands, From B2B to Outreach

Ready To Go!

Bring your vision to life

Have a project brewing? Let’s chat and explore how we can help you bring it to life. Share your ideas and let’s get started.