Git Bisecting/Finding faulty commits Semi-automatically find a faulty commit


Example

Imagine you are on the master branch and something is not working as expected (a regression was introduced), but you don't know where. All you know is, that is was working in the last release (which was e.g., tagged or you know the commit hash, lets take old-rel here).

Git has help for you, finding the faulty commit which introduced the regression with a very low number of steps (binary search).

First of all start bisecting:

git bisect start master old-rel

This will tell git that master is a broken revision (or the first broken version) and old-rel is the last known version.

Git will now check out a detached head in the middle of both commits. Now, you can do your testing. Depending on whether it works or not issue

git bisect good

or

git bisect bad

. In case this commit cannot be tested, you can easily git reset and test that one, git willl take care of this.

After a few steps git will output the faulty commit hash.

In order to abort the bisect process just issue

git bisect reset

and git will restore the previous state.