Gitflow
🚒Hotfix During Feature WorkMedium+500 XP
Workshop
Scenario reference

Hotfix During Feature Work: the situation, step by step

The situation

Deep in feature dev when P0 production bug hits. Must fix, deploy, then resume without losing anything.

Feature branch has uncommitted changes. Bug is in payment module — separate from your feature.

Medium · 7 steps · +500 XP

What you will practice

This scenario walks through 7 steps, in order:

  1. 01Stash WIP (include untracked)
  2. 02Switch to main
  3. 03Create hotfix branch
  4. 04Fix and commit
  5. 05Push hotfix
  6. 06Switch back to feature
  7. 07Restore stash
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. Stash WIP (include untracked)
    git stash -u
  2. 2. Switch to main
    git switch main
  3. 3. Create hotfix branch
    git switch -c hotfix/payment
  4. 4. Fix and commit
    git commit -am "fix: payment null"
  5. 5. Push hotfix
    git push -u origin hotfix/payment
  6. 6. Switch back to feature
    git switch feature-analytics
  7. 7. Restore stash
    git stash pop

Key takeaway

Hotfix shipped, feature restored! Stash + branching = zero loss.