Posts | About

Git Bisect | Automatically Find Your Bugs

gitcheat-sheetsvideo

Posted on 2024-09-06 by Matt.

Cheat Sheet

git bisect docs or git bisect --help

git bisect does a binary search from a commit known to be good to a commit known to be bad, finding the first commit that contains the bug.

Begin bisect process.

$ git bisect start
status: waiting for both good and bad commits

Specify that the currently checked out commit (HEAD) has the bug, and that 7e01f02 is an ealier commit that did not contain the bug.

$ git bisect bad
status: waiting for good commit(s), bad commit known
$ git bisect good 7e01f02
Bisecting: ...

You can specify a branch or a tag instead.

# the latest commit on branch develop is good
$ git bisect good develop
# version 3.1.0 is good
$ git bisect good 3.1.0

Mark a commit as good or bad as the process goes along

$ git bisect good
$ git bisect bad

Skip over the current commit (e.g. it doesn't compile)

$ git bisect skip

When you are finished, return back to the commit you had checked out when starting the bisect

$ git bisect reset

Automate the check. Git will run check.sh after checking out each commit.

$ git bisect run check.sh