Git Worktrees Changed My Branching Workflow
The Problem
I’d be deep into a feature branch when a critical bug comes in. The stash-switch-fix-switch-unstash dance was getting old:
git stash
git checkout main
git checkout -b hotfix/urgent-thing
# fix, commit, push
git checkout feature/my-thing
git stash pop
# hope nothing conflicts
The Solution
git worktree add ../project-hotfix main
cd ../project-hotfix
git checkout -b hotfix/urgent-thing
# fix, commit, push
cd ../project
git worktree remove ../project-hotfix
Why It Works
Git worktrees let you check out multiple branches into separate directories simultaneously. Each worktree shares the same .git history but has its own working directory.
My structure now:
~/code/
project/ # main development
project-hotfix/ # temporary for fixes
project-review/ # for reviewing PRs
No stashing. No context switching. Each branch lives in its own space.
The only catch: you can’t have the same branch checked out in multiple worktrees. But that’s rarely a problem in practice.
I resisted learning this for years because it seemed complicated. It’s not. Should have done it sooner.