Advanced

How to use git bisect to find bugs

Use binary search to find which commit introduced a bug.

1. Start bisect
git bisect start

Begins the bisect session.

2. Mark current commit as bad
git bisect bad

Tells git the current commit has the bug.

3. Mark a known good commit
git bisect good v1.0.0

Tells git a known good commit (a tag, hash or relative ref). Git will check out the midpoint.

4. Mark each checked-out commit
git bisect good
# or
git bisect bad

Test the currently checked-out commit and mark it. Git narrows down the range each time.

5. End bisect
git bisect reset

Ends the bisect session and returns to your original branch.

← Back to Git Reference