32 / 57 · 17 Git & Version Control · Bisect and Cherry-Pick← prev⊞ allnext →☰ Read as one page
5.2How Bisect Works
You tell Git one "good" commit (where the test passed) and one "bad" commit (where the test fails). Git checks out the midpoint and asks you to evaluate it. Based on your answer, it narrows the range by half and repeats.
Commit history: A B C D E F G H I J K L M N O P
good? bad
Step 1: Git checks out H (midpoint)
→ You test: PASS → good
Range narrows to: I J K L M N O P
Step 2: Git checks out L (midpoint of remaining)
→ You test: FAIL → bad
Range narrows to: I J K L
Step 3: Git checks out J (midpoint)
→ You test: PASS → good
Range narrows to: K L
Step 4: Git checks out K
→ You test: FAIL → bad
Result: K is the first bad commit
Four steps to find the problem among 16 commits.