Menu

1 / 2

I Stopped Switching Git Branches — And Started Using Worktrees Instead

DEV Community: javascript·Sulthon Zainul Habib·6 months ago
#5xJlgKyb
#dev#worktrees#feature#branch#article
Reading 0:00
15s threshold

I used to be a git stash person. You know the dance — you're halfway through a feature, someone pings you about a bug on main, and suddenly you're stashing, switching, fixing, switching back, popping, and praying the stash applies cleanly.

Then I discovered git worktrees. And then I discovered why nobody uses them — the UX is awful .

The Problem With Branch Switching

Here's a typical afternoon for me:

Working on feature/payment-flow in VS Code

Production bug comes in, needs a hotfix on main

Stash changes (12 files modified)

git checkout main

Apply hotfix, test, push

git checkout feature/payment-flow

git stash pop — conflict. Of course.

Spend 20 minutes resolving stash conflicts that have nothing to do with my actual work

Multiply this by 3-4 context switches a day and I'm losing an hour just to git gymnastics.

Git Worktrees: The Concept

Git worktrees let you have multiple checkouts of the same repo simultaneously.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.