Gitflow
🌳Two Branches at Once with WorktreeMedium+550 XP
Workshop
Scenario reference

Two Branches at Once with 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. Switching branches will break your dev server.

git worktree gives you a second checkout in a sibling directory — same repo, different branch.

Medium · 2 steps · +550 XP

What you will practice

This scenario walks through 2 steps, in order:

  1. 01Create a worktree for the hotfix
  2. 02List worktrees to confirm
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. Create a worktree for the hotfix
    git worktree add ../app-hotfix main
  2. 2. List worktrees to confirm
    git worktree list

Key takeaway

Worktrees beat stashing for context switches. One repo, many checkouts.