git bisect
A command that finds the commit that introduced a bug by binary search: you mark commits good or bad and Git checks out the next one to test.
In more detail
Start with git bisect start, mark the current commit bad and a known older commit good, and Git picks the commit halfway between. Each answer halves the range, so about ten tests search a thousand commits. git bisect reset returns you to where you started, and small commits make the result precise.
Examples
git bisect startgit bisect good HEAD~2Related terms
- binary search — Finding a target in sorted data by comparing it with the middle item and throwing away the half where it cannot be.
- bug — A mistake in a program that makes it fail or behave wrongly.
- git blame — The command that shows, for each line of a file, the commit, author and date that last changed it.
Taught in
- DevOps Sprint: Tax At A Hundred Percent — CompTIA Cloud+ (CV0-004) Exam Prep
- Exam On Thursday: The PBQ Clinic And Final Review — CompTIA Cloud+ (CV0-004) Exam Prep
- Staging Deliberately: status, add, add --patch — Advanced Git Internals & Distributed Workflows
- Committing, And What A Good Message Says — Advanced Git Internals & Distributed Workflows
- Investigating History: blame, bisect And worktree — Advanced Git Internals & Distributed Workflows