Back to lessons
Finding Bugs with Bisect
Use binary search to pinpoint which commit introduced a bug.
Step 1 of 520%
git bisect uses binary search to find the exact commit that introduced a bug. It's incredibly efficient — finding a bug among 1000 commits takes only 10 steps.
Binary search is one of the most efficient algorithms in computer science, and git bisect brings it to your debugging workflow. Instead of manually checking commits one by one, Git does the heavy lifting: it checks out a commit halfway between good and bad, you mark it as good or bad, and it repeats until the culprit is found. With 1000 commits, that's just 10 tests instead of potentially hundreds.
1 / 5