git bisect provides easy to use binary search approach in order to find a bad commit. This tip assumes you know how it works is in general, but always forget what the commands are precisely.

  1. Prepare a single command that tries to reproduce the bug (e.g. script, test) off tree. Bisect is about to start jumping around, so it can’t be in the tree.

  2. git bisect start: begin the bisect session.

  3. git bisect bad: mark current HEAD as a bad commit (i.e. the bug is reproducible).

  4. git bisect good <commit-ref>: some known commit in the past, where the bug does not exist.

  5. You get dropped at a given commit. Try the command/test/script from step 1 and:

    • if the bug exists: git bisect bad
    • if the bug does NOT exist: git bisect good
  6. Repeat until the initial bad commit is found. 7 git bisect reset.