Finding a Bug with Bisect
Git bisect.
Your site worked fine a few weeks ago. Now the page is blank, and there are dozens of commits in between. Which one broke it? Git bisect finds it for you, by cutting the search in half, again and again.

- It worked weeks ago
- Now it's broken
- Which commit did it?
A tiny test
First, we need a way to test a commit. This little script checks that the style file doesn't hide the page. It exits with success when the page is fine, and failure when it's broken.
#!/bin/sh
# good if the page is visible
! grep -q "display: none" style.cssgit bisect
Git bisect start. Mark the current commit as bad. Mark the very first commit as good. Then git bisect run, with our test. Git checks out a commit halfway between, runs the test, and keeps halving. In a few steps, it names the first bad commit. Tidy styles, the commit that added display none. Finally, bisect reset takes us back to where we started.
git bisect start status: waiting for both good and bad commits git bisect bad status: waiting for good commit(s), bad commit known git bisect good f7d9757 Bisecting: 5 revisions left to test after this (roughly 3 steps) [bed2a1ab49ea623f9f80d82bf7f5af5b3d51c51c] Improve paragraph spacing git bisect run sh test.sh running 'sh' 'test.sh' Bisecting: 2 revisions left to test after this (roughly 2 steps) [4f3385b981fa425add46f7da1cd423ab6e55c80a] Add footer running 'sh' 'test.sh' Bisecting: 0 revisions left to test after this (roughly 1 step) [f325c1bc25cdf8e5fddd7e3d7309d7dd5541d50b] Expand about page running 'sh' 'test.sh' Bisecting: 0 revisions left to test after this (roughly 0 steps) [5a9a3544a95b4dbe964d6c3ed106972a1fd0cdcf] Tidy styles running 'sh' 'test.sh' 5a9a3544a95b4dbe964d6c3ed106972a1fd0cdcf is the first bad commit commit 5a9a3544a95b4dbe964d6c3ed106972a1fd0cdcf Author: Sam Lee <sam@example.com> Date: Mon Jan 5 09:47:57 2026 +0000 Tidy styles style.css | 1 + 1 file changed, 1 insertion(+) bisect found first bad commit git bisect reset Previous HEAD position was 5a9a354 Tidy styles Switched to branch 'main'
Summary
Git bisect searches your history by halving it, to find the commit that broke something. Next, making Git faster to type.
Key takeaways- git bisect start
- bad, good, then run
- git bisect reset