TIL: Git Worktrees Are a Game Changer

How git worktrees let you work on multiple branches simultaneously without stashing or switching.

Today I learned about git worktree and I wish I’d known about it sooner.

The problem

You’re deep in a feature branch. A bug comes in. You need to switch to main, but you have uncommitted changes. Options: stash, commit WIP, or lose your flow.

The solution

git worktree add ../hotfix main

This creates a new working directory checked out to main. You now have two directories, each on a different branch. No stashing. No context switching. Just cd into the other directory.

Clean up

When you’re done:

git worktree remove ../hotfix

Why this matters

It preserves your mental context. The feature branch directory stays exactly as you left it — editor state, terminal history, everything.

I’m adding this to my permanent workflow.