Git & GitHub Interview Question #139
How do you handle a production bug when main has already moved ahead?
Security, Team Workflows, Troubleshooting & Senior Git/GitHub Scenarios Senior Advanced
Quick Interview Answer
First identify the exact production version or commit and understand whether the current main branch can safely produce the fix. If production is maintained on a separate release line, create the fix from the appropriate release commit or branch rather than blindly deploying unrelated main changes.
Detailed Explanation
First identify the exact production version or commit and understand whether the current main branch can safely produce the fix. If production is maintained on a separate release line, create the fix from the appropriate release commit or branch rather than blindly deploying unrelated main changes.
After validating the fix, integrate it back into other branches that need it using the team's normal merge or cherry-pick policy. Tags and release branches make this situation easier to reason about.
Code Example
# Example: fix from a maintained release branch
git fetch origin
git switch release/2.3
git switch -c hotfix/critical-auth
# After the fix is committed, integrate it into
# other required branches according to team policy.