A critical bug was discovered in production today. The app was working perfectly in release v1.0 three months ago, but somewhere among the 800 commits made since then, someone broke user checkout. Testing all 800 commits manually would take three days. Git Bisect uses a binary search algorithm to find the exact breaking commit in just 10 tests!
Instead of testing commits sequentially from 1 to 800, Git Bisect cuts the search space in half with every test:
800 → 400 → 200 → 100 → 50 → 25 → 12 → 6 → 3 → 1!
In mathematically at most (lceil log_2(800) ceil = 10) steps, Git pinpoints the guilty commit!
# Step 1: Start the bisect session
$ git bisect start
# Step 2: Mark current state as broken (bad)
$ git bisect bad
# Step 3: Tell Git a known historical good commit or tag
$ git bisect good v1.0.0
Bisecting: 400 revisions left to test after this (roughly 9 steps)
[3a1b2c4] refactor(cart): update tax calculations
Git automatically checks out the commit exactly halfway between good and bad. You test your application (in browser or running tests):
# If the bug is present:
$ git bisect bad
# If the bug is NOT present (checkout works):
$ git bisect good
Bisecting: 200 revisions left to test after this (roughly 8 steps)
Repeat this quick check. Within minutes, Git declares the culprit with surgical precision:
7d1935a4b2c1d0e is the first bad commit
commit 7d1935a4b2c1d0e
Author: Alice Smith
Date: Wed Oct 14 14:22:10 2026 +0000
refactor(checkout): change currency rounding algorithm
src/services/checkout.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
# Step 4: End session and return to original branch
$ git bisect reset
git bisect runIf you have an automated test script (e.g. npm test or a shell script test.sh that returns exit code 0 for success and non-zero for failure), Git can test all 800 commits with zero human intervention:
$ git bisect start HEAD v1.0.0
$ git bisect run npm test
# Git checks out, tests, and finds the culprit in 15 seconds!
$ git bisect reset
Strengthen your version control mastery by studying these connected classes:
Identify candidate good and bad commit ranges before launching bisect runs.
Pinpoint exact authors and commit lines once bisect identifies the faulty commit.
Run git bisect run with automated test scripts to locate bugs in seconds.
Explain the logarithmic O(log N) time complexity of binary search debugging.
Advance your software engineering skills with the next topic in our synchronized curriculum.
Continue to git blame & Search → Previous: ← git reflog Recovery | Full Syllabus