0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
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.
The most common purpose of 'git bisect' is to...