CodeBlanks Logo Icon CodeBlanks

git bisect

Learn to find the bug commit with git bisect.

Introduction to git bisect

git bisect helps identify the commit that introduced a bug. Git uses binary search between a known working commit and a commit containing the bug. This narrows the search much faster than checking every commit individually.

git bisect start

During the search, Git asks you to inspect specific commits. By reporting each result, you can find the commit where the bug first appeared.

Starting a bisect search

First, start the search with git bisect start. Then identify a revision containing the bug and an older revision where the bug was not present. Git searches the commits between these two references.

git bisect start
git bisect bad
git bisect good HEAD~8

In this example, the current commit is bad, while the commit eight revisions earlier is known to work.

Practice Start a bisect search and inspect a revision

Start a bisect search. Then run the command that displays the commit ID of the currently selected revision.

Starter code

terminal
# Bisect aramasını başlat

# Seçili commit kimliğini göster

Sample solution

terminal
git bisect start
git rev-parse --short HEAD

Expected output

Bisect session started.
Current revision displayed.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which method helps find the commit that introduced a bug with fewer checks?

  • Binary search Correct answer
  • File comparison
  • Branch merging
  • Linear search

Explanation: git bisect uses binary search to narrow the commit range at each step.

2 Start the bisect search

Question
git ____
Answer
git bisect start

Explanation: The correct command for starting a bisect search is git bisect start.

3 Basic bisect concepts

Term Meaning
git bisect Searches for the bug-introducing commit
İkili arama Narrows the range step by step
Bug An incorrect behavior or issue
Commit aralığı The set of revisions to inspect

All lessons in Advanced