git bisect
Uses binary search to find the commit that introduced a bug.
Syntax
git bisect <subcommand>
Options
- start: Begins the bisect session
- bad [<rev>]: Marks a commit as containing the bug
- good [<rev>]: Marks a commit as not containing the bug
- reset: Ends the bisect session and returns to the original branch
- skip: Skips the current commit if it cannot be tested
- log: Shows what has been done so far
- run <cmd>: Automates bisect by running a script for each step
Example
git bisect start git bisect bad git bisect good v1.0.0 # Git checks out a commit to test git bisect good # or: git bisect bad git bisect reset
Tip
Automate bisecting with git bisect run <test-script> to find bugs without manual testing.