Production has a bug, but `main` already contains unreleased features. How do you ship a hotfix?
IntermediateScenarioBranching Strategies and Releases
Answer
Situation read → Deploying main would ship unfinished work.
What I'd do →
- Branch from the production tag:
git switch -c hotfix/1.8.1 v1.8.0. - Apply the minimal fix, test, and tag
v1.8.1; deploy that tag. - Port the fix to
main:git cherry-pick -xor merge the hotfix branch forward. - Write a short post-incident note linking both PRs.
Why → The hotfix ships only the fix; main gets it later so it is not lost.
Interview tip → Feature flags reduce hotfix branches, since you can often disable the new feature instead.
More on Branching Strategies and Releases
An eight-person team deploys several times a day. Which branching strategy do you recommend?IntermediateWhen would you choose GitFlow over trunk-based development?IntermediateIn trunk-based development, a feature will take three weeks. How do you merge it daily without exposing it?IntermediateYou are cutting a release. How do you manage the release branch and late fixes?IntermediateShould releases use lightweight or annotated tags?BeginnerA release tag was placed on the wrong commit and has been published. What do you do?Intermediate