Bisect

Bisecting allows you to identify which commit within a given search space introduced a given bug by executing the specified repro command once per commit, narrowing down the search space from the centre at each step.

The verbose way

Start a new bisect session:

git bisect start

Give the first known-bad ref:

git bisect bad HEAD

And the last known-good ref, at which point Git will move HEAD to the midpoint commit:

git bisect good origin/master

We now run our tests, and report the build as either good or bad:

git bisect good
# or
git bisect bad

Repeat this until the offending commit is found, then reset the session:

git bisect reset

Shorthand

We can condense this if the build script exits with zero on success and non-zero on error:

git bisect start HEAD origin/master
git bisect run make test

Once you've found the bad commit:

git bisect reset