How to use Git to hunt for bugs origin

When a bug happens, its origin is not always obvious

Debugging to find where it comes from can be tedious

It is often possible to know roughly when it used to work (master, yesterday, last release...)

Is it possible to narrow down even more the set of potential breaking changes?

git bisect

Use binary search to find the commit that introduced a bug

git-bisect man page

git bisect

principle

git bisect

commands

git bisect start

git bisect good <known good commit>

git bisect bad <known bad commit>

test

git bisect good OR git bisect bad depending on test result

1:

2:

3:

4:

5:

Go to 6 and repeat until the end

6:

git bisect reset (to exit the bisect mode)

7:

git bisect

pros/cons

git bisect

limits

every commit must be working to be able to properly test

better with atomic and targeted commits

Made with Slides.com