Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What do you need before you can use git bisect?

SHORT ANSWER

A known bad commit, a known good commit earlier in history, and a way to test the bug at each step, either by hand or with a script. A clean working tree also helps.

Explain it simply

Binary search needs a sorted range with a clear boundary: before it works, after it is broken. If the bug appears and disappears randomly, bisect gives nonsense.

So first make the failure reproducible, such as a failing test or clear manual steps. Then find an old version where it worked, perhaps a release tag. Commit or stash local changes, because Git will check out many commits. Mark the ends and begin.

Example

bash
git stash -u
git bisect start
git bisect bad HEAD
git bisect good v1.2.0

What to say in the interview

"I need a reproducible test, one known good commit and one known bad commit, and a clean working tree. If the bug is flaky bisect cannot be trusted."

#git#bisect#prerequisites

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.