← All writing
Craft · · 2 min

git bisect

Git Debugging Small Print

Somebody says the search results have looked wrong since sometime in January. There are 300 commits since January and none of the messages say anything about search.

terminal
git bisect start
git bisect bad
git bisect good v2.1.0
Text

Git checks out a commit halfway between the two, you look, you say git bisect good or git bisect bad, and it halves again. 300 commits is nine of those. Then git bisect reset to get back.

The commands aren’t worth practicing. It is deciding, out loud, before you start, exactly what makes a build good or bad. “Search looks wrong” is not a test. “Searching for a two-word phrase returns zero results” is. If you cannot state it in one sentence you will get four steps in, hit an ambiguous one, and poison the whole run without noticing.

git bisect run ./check.sh will do the whole thing unattended if you can write that sentence as a script that exits non-zero. I do this less often than I should, mostly because by the time I think of it I am already three manual steps in.

It has never once felt like much while I was doing it. It is nine builds and a lot of waiting. But it turns “somebody will have to read the diff” into a chore with a known length, and it does not care how big the codebase is.

Read similar posts
2 min

git reflog

Almost nothing is actually gone after a bad reset, because git keeps a local log of everywhere HEAD has pointed for the last ninety days and hardly anybody knows to look at it.

2 min

light-dark()

Two color values in one declaration, picked by the color scheme, which removes most of the reason a theme needed a second block of custom properties at all.