CodeBlanks Logo Icon CodeBlanks

Summary - Bisect

Combine the bisect flow to find the buggy commit.

Summary: Bisect workflow

To find which commit introduced a bug, start with git bisect start. Mark the faulty revision as bad and a working revision as good. Git narrows the range using binary search and selects a new commit at each step.

git bisect start
git bisect bad HEAD
git bisect good v1.0.0

You can inspect each commit manually or automate testing with git bisect run.

Practice Find the faulty commit automatically

Start a bisect session. Mark the current commit as bad and the v1.5.0 tag as a working revision. Then run ./check-bug.sh automatically and reset the session when the search is complete.

Starter code

terminal
# Bisect oturumunu başlat

# Mevcut commit hatalı

# v1.5.0 çalışan sürüm

# Testi otomatik çalıştır

# Oturumu bitir

Sample solution

terminal
git bisect start
git bisect bad HEAD
git bisect good v1.5.0
git bisect run ./check-bug.sh
git bisect reset

Expected output

Bisect session started.
Current commit marked bad.
v1.5.0 marked good.
Automated test completed.
Bisect session reset.

Questions and answers

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

1 Git has identified the commit where the bug began. Which command ends the bisect session and returns to the previous branch state?

  • git bisect good
  • git bisect reset Correct answer
  • git bisect run
  • git bisect bad

Explanation: git bisect reset ends the bisect session and returns to the original HEAD position.

2 Automated search and testing

Question
git bisect ____
Answer
git bisect run ./check-bug.sh

Explanation: Use git bisect run to execute the specified script automatically throughout the search.

3 Roles of bisect commands

Term Meaning
git bisect start Starts the search session
git bisect good Marks a working commit
git bisect bad Marks a faulty commit
git bisect run Runs the test automatically

All lessons in Advanced