HotfixA critical bug fix that bypasses the normal release process. Branch directly from main (or a release tag), fix, tag a new patch version, and merge back to main. Speed matters.
Stash context switchWhen an urgent bug interrupts your work, use git stash to save your in-progress changes, switch to main, and create the hotfix. Afterward, switch back and stash pop to resume.
Porting fixesAfter merging the hotfix to main, cherry-pick it onto your feature branch too. This keeps the feature branch up to date with the fix, preventing regressions when the feature is eventually merged.
📖 Story
Production is down! Users can't log in — the login function is returning "broken". You're in the middle of building a dashboard feature, but this is critical.
Drop everything: switch to main, create a hotfix branch, fix the bug in the editor, commit, tag v1.0.1, and merge back to main.
But don't forget your feature branch — cherry-pick the same fix there too, so it stays up to date.
This is the real hotfix workflow: urgent fix, tag, merge, and port to active branches.
View all branches
Run git log --oneline --all. You're working on feature/dashboard (WIP). Main is at h2b3c4d. The login is returning "broken" — a production bug!
● View all branches
○ Switch to main
○ Create a hotfix branch
○ Fix the bug and stage it
○ Commit the hotfix
○ Tag the hotfix release
○ Switch back to main
○ Merge the hotfix into main
○ Switch back to your feature branch
○ Cherry-pick the fix into the feature branch
Terminal
📘 Starting tutorial: Hotfix Workflow
Drop everything to fix a production bug: branch, edit, commit, tag, merge, and port to your feature branch