Log inStart free
LESSON 1.19 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Git bisect

Watch git bisect halve the suspect commits until one bad commit is left.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 1.19 · BISECT BAY15 SUSPECTS · 0 TESTS
01
Stage 1 of 6 · Mark the ends
v1.0 passes the test, and main fails it. The 15 commits after v1.0 are suspects.
Explain it simply

Your code worked at the tag v1.0, but it's broken on main. A test shows it: add of 2 and 2 should give 4. Each commit is a saved snapshot of the code. One of the 15 commits after v1.0 brought the bug in, so all 15 are suspects, the teal dots.

16 commits in a row, c0 to c15. c0 is tagged v1.0 and passes. c15 is main and fails. 15 commits are suspects.

suspect commitHEAD, the commit under testgood commitbad commitfirst bad commit, test count
historysuspectsterminalv1.0mainHEADc0c1c2c3c4c5c6c7c8c9c10c11c12c13c14c1515$ git rev-list --count v1.0..main15historysuspectsterminalv1.0mainHEADc0c1c2c3c4c5c6c7c8c9c10c11c12c13c14c1515$ git rev-list --count v1.0..main15
Toy: a real git repository · 8, 16 or 32 commits in a line · real hashes · one test
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
N=#{ c:good<c≤bad }\sy{N}{data}{N} = \#\{\, c : \sy{good}{ink}{\text{good}} < c \le \sy{bad}{grad}{\text{bad}} \,\}
N=15(c1…c15)N = 15\quad (c_{1} \dots c_{15})

N counts the commits after the good one, up to the bad one.

Common mix-ups

MYTHBisect checks every commit between good and bad.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Double the history from 16 to 32 commits. How many tests does bisect need now?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.