In this lesson, you let git halve the history for you. A 120-line order went through at release v1.0 but is declined at v1.5, with twelve commits in between and no file to start from.
Key Points
- A check that decides good or bad for exactly one behavior. You save it outside the repo, in your checks folder. Committed to the repo, it would be missing at older commits. It builds its own data, so nothing needs seeding between commits. Git counts any error as bad, so an older
createOrder()needing a field this toy state lacks would throw too and mislead the search. Such a commit should be skipped. The exercise shows how your check tells git. - Check both ends first.
git checkout v1.0swaps in that release’s files (git warns that you’re not on a branch, which is fine here), and the check passes. At v1.5, it fails. Thengit switch maintakes you back to where you started. A release you remember as good may not be. A search is only as trustworthy as its two ends. git bisect start <bad> <good>sets up the search, bad commit first, and checks out the commit halfway between.git bisect run <command>runs your check at each stop.
Git ignores what the check prints. An uncaught error makes Node report a failure, which means bad, and a clean end means good.
Bisect assumes the behavior changed once, so everything before a good commit is good.