Binary search for bugs
I recently encountered a build failure in a dependency of a Rust
crate I was trying to install which led me to be introduced to a git
From the official docs found over at git-scm.com, the small description under the name heading reads:
Use binary search to find the commit that introduced a bug
Sounds super cool right? Using this feature I was able to track down the commit that introduced the bug in less than 6 steps.
Here’s a general overview of how this command works:
git bisect startto start the bisect session
Specify a bad commit (usually HEAD) using
git bisect bad <commit-id>
Specify a good commit using
git bisect good <commit-id>
This will kick off the binary search and pick a new commit in which
you can evaluate using
git bisect good or
git bisect bad, in between the two endpoints.
It is clear that using this method, over the linear scan approach, can save a tremendous amount of time in the quest for finding where a breaking change was introduced.
I am compsci undergrad with a minor in mathematics @ mcgill university, programmer and rationalist. For fun I enjoy working on open-source projects, reading, and lifting weights.
Send me a message by email: liam [at] scalzulli.com or matrix: worse:matrix.org