Git bisect is hugely useful. If you work on a team, or within a monorepo, finding the commit that introduces a regression is often time consuming. No more!
First, put your repo into a state where the bug or regression is visible.
git checkout $BAD_REF
Start the bisect session and mark the repo as “bad”.
git bisect start git bisect bad
Next, put the repo into a state where the bug or regression is no longer visible.
git checkout $GOOD_REF git bisect good
This kicks off an automated binary search to locate the offending commit. Git will pause several times and ask you to confirm if the bug or regression is visible. Use
git bisect bad
git bisect good
to continue the process. Eventually, Git will identify the offending commit.
git bisect good c7c4c87452501f8d4982f2bfa518dc0bc7b9242f is the first bad commit