git bisect - Hunt the Bad Commit

git bisect - binary search your history

Scenario: A test passed last week but fails today, and there are 200 commits in between. Checking each by hand is madness. git bisect does a binary search - ~8 checks for 200 commits - to pinpoint the exact commit that broke it.
$ git bisect start
$ git bisect bad                 # current commit is broken
$ git bisect good v1.2.0         # this old tag worked
# Git checks out a commit halfway between. Test it, then tell Git:
$ git bisect good                # or: git bisect bad
# ...repeat until Git prints the first bad commit...
$ git bisect reset               # return to where you started
CommandMeaning
git bisect startBegin a bisect session
git bisect bad [commit]Mark a commit as broken
git bisect good [commit]Mark a commit as working
git bisect resetEnd and go back
git bisect run ./test.shAutomate - Git runs the script to judge each commit
Tip: git bisect run <script> fully automates the hunt: Git checks out each candidate, runs your test script (exit 0 = good, non-zero = bad), and reports the culprit - hands-free.