Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is git bisect, and when would you use it?

SHORT ANSWER

git bisect does a binary search through commit history to find the exact commit that introduced a bug. You mark one good and one bad commit, and Git checks out midpoints until it finds the first bad one.

Explain it simply

A bug appeared somewhere in the last 200 commits and nobody knows where. Checking each would take forever. Bisect plays the number-guessing game: 'I am thinking of a number from 1 to 200'; each answer halves the options.

You tell Git a commit where it worked and one where it is broken. Git checks out the middle one; you test and answer good or bad; it halves again. About eight steps cover 200 commits, since 2 to the power 8 is 256. At the end Git names the first bad commit. Finish with git bisect reset.

Example

bash
git bisect start
git bisect bad                 # current version is broken
git bisect good v1.4.0         # this tag worked
# Git checks out a middle commit; test it, then:
git bisect good    # or: git bisect bad
git bisect reset

What to say in the interview

"git bisect binary-searches history for the commit that introduced a bug. I mark a good and a bad commit, then answer good or bad for each commit Git checks out. It takes about log2(n) steps, and git bisect reset takes me back."

#git#bisect#debugging

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.