

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Bisect
incomplete
2: How to Bisect
incomplete
3: That Was Annoying
incomplete
This lesson's interactive features are locked, please to keep using them
Click to play video
So we know how to fix problems in our code. We can either:
But there's another question:
How do we find out when a bug was introduced?
That's where the git bisect command comes in. Instead of manually checking all the commits (O(n) for Big O nerds), git bisect allows us to do a binary search (O(log n) for Big O nerds) to find the commit that introduced the bug.
For example, if you have 100 commits that might contain the bug, with git bisect you only need to check 7 commits to find the one that introduced the bug.
| commits to check | max checks to find |
|---|---|
| 1 | 1 |
| ---------------- | -------------------- |
| 2 | 1 |
| ---------------- | -------------------- |
| 10 | 4 |
| ---------------- | -------------------- |
| 100 | 7 |
| ---------------- | -------------------- |
| 1000 | 10 |
| ---------------- | -------------------- |
| 10000 | 14 |
git bisect isn't just for bugs, it can be used to find the commit that introduced any change, but issues like bugs and performance regressions are a common use case.