Gitflow
🌳Context Switch Without a WorktreeMedium+550 XP
Scenario reference

Context Switch Without a Worktree: the situation, step by step

The situation

You're deep in a feature branch with a half-broken build. Production page is on fire and the fix belongs on main.

`git worktree add` gives you a second checkout in a sibling directory — it needs a real second working directory, which this browser engine has not got. The portable fallback is stash → switch → fix → switch back → pop.

Medium · 4 steps · +550 XP

What you will practice

This scenario walks through 4 steps, in order:

  1. 01Park the half-finished work, untracked files included
  2. 02Switch to main to do the hotfix
  3. 03Go back to the feature branch
  4. 04Restore the parked work
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Park the half-finished work, untracked files included
    git stash -u
  2. 2. Switch to main to do the hotfix
    git switch main
  3. 3. Go back to the feature branch
    git switch feature-deep
  4. 4. Restore the parked work
    git stash pop

Key takeaway

Stash-and-switch is the fallback every Git has. When you can use a worktree, prefer it: your half-broken build stays on disk untouched instead of being parked in a stash.