Interview Prep/Git & GitHub/Branching and Merging Workflows

A bug appeared sometime in the last 200 commits. How do you find the culprit fast?

IntermediateScenarioBranching and Merging Workflows
Answer

Situation read → Binary search over history needs a known good commit and a reliable test.

What I'd do →

  1. Start: git bisect start, git bisect bad HEAD, git bisect good v2.1.0.
  2. Automate with a script that exits 0 for good and non-zero for bad:
git bisect run ./scripts/repro.sh
git bisect reset
  1. Read the reported first bad commit and inspect it with git show.

Why → 200 commits need about 8 steps. Exit code 125 in the script tells bisect to skip an untestable commit.

Interview tip → Linear history (squash or rebase) makes bisect cleaner, since merge commits can confuse results.

All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and Merging Workflows