Git bisect

Use bisect to determine which commit introduced a bug.

Given a list of commits somewhere before and after the bug was introduced, git will check out the commit in the middle for you to test if it contains the bug. If it does, it will check out the commit halfway to the starting point (because the bug was introduced before this commit). If it does not contain the bug, it will check out the commit half way to the end point (because the bug was introduced after this commit.

This process repeats, jumping to the middle of the list to divide it in half, checking for the bug, and jumping to the next point. This is a list searching strategy called bisecting, which helps rapidly find an item in a sorted list.

git bisect start

Roll back to an older commit that does not have the bug.

git checkout [good commit]

git bisect good

Follow the prompts to find the buggy commit. That will point you to the fix in buggy branch, or you can revert this one and reapply it as a future commit.

 

Topics