Gitflow
🩹Hotfix on main While Feature Work ContinuesMedium+550 XP
Workshop
Scenario reference

Hotfix on main While Feature Work Continues: the situation, step by step

The situation

Customers report a P1 bug in production. Feature work on `develop` continues. You need to ship a fix from main, tag it, and merge it into develop too.

Branch from main, fix, merge back, tag, then merge main into develop.

Medium · 6 steps · +550 XP

What you will practice

This scenario walks through 6 steps, in order:

  1. 01Create the hotfix branch from main
  2. 02Commit the fix
  3. 03Switch back to main and merge the hotfix
  4. 04Merge the hotfix
  5. 05Tag the release
  6. 06Push everything including the tag
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 the hotfix branch from main
    git switch -c hotfix/v2.3.1
  2. 2. Commit the fix
    git commit -am "fix: null pointer in checkout"
  3. 3. Switch back to main and merge the hotfix
    git switch main
  4. 4. Merge the hotfix
    git merge --no-ff hotfix/v2.3.1
  5. 5. Tag the release
    git tag -a v2.3.1 -m "Hotfix"
  6. 6. Push everything including the tag
    git push --follow-tags

Key takeaway

Hotfixes flow from main → tag → back-merge to develop. Always tag releases.