When a pushed commit breaks the build, the priority is restoring a working build quickly, then fixing the underlying issue properly with the original author's context rather than guessing at a patch.
Key Points: • Use git bisect, or simply the CI logs, to pinpoint exactly which commit introduced the failure. • Talk to the commit's author to understand their intent before assuming the change is simply wrong. • git revert the breaking commit to restore a green build quickly, buying time to investigate without leaving the team blocked. • Collaborate with the author on a proper fix, and consider adding a test that would have caught the regression. • Recommit the corrected change once it's verified, keeping the CI pipeline green throughout the process.
Example: The build turns red right after a teammate's push; git bisect (or the CI history) confirms their commit as the cause, so the team reverts it immediately to unblock everyone, then works with the author to land a properly fixed version with a regression test.
Code Example:
git bisect start
git bisect bad HEAD
git bisect good v1.4.0Interview Tip: A concise interview answer is:
"I'd first confirm which commit broke the build, using bisect or the CI logs, then revert it to restore a green build quickly rather than leaving the team blocked. From there I'd work with the author on a proper fix, ideally with a test added, before recommitting."