Boss lesson · Unit 03
Find the commit that broke it
Binary search over history with git bisect
What you practise
git bisectis binary search over history: good, bad, halve- How many steps for n commits
- Automating with
git bisect run git blameandgit log -S
Try a question from this lesson
Pick one
A test passed 1,000 commits ago and fails now. Checking one commit takes a minute. About how many checks does a smart search need to find the commit that broke it?
Correct answer
About 10
Why
Test the commit in the middle. If it passes, the culprit is in the newer half; if it fails, in the older half. Each test halves the suspects, and 1,000 halves down to 1 in about 10 steps.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Binary search over history
git bisect is binary search on commits. You name one commit where things worked (good) and one where they are broken (bad). Git checks out a commit halfway between and you tell it: good or bad?
Each answer halves the suspects, until one commit is left: the first bad one.
c1 c2 c3 c4 c5 c6 c7 c8 c9
good ^^ bad
tested first11 more exercises in the app
- 4× multiple choice
- 2× fill the blanks
- 2× type the answer
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.