CodeBlanks Logo Icon CodeBlanks

good and bad

Learn the search with good and bad references.

good and bad references

In a bisect search, good identifies a working commit without the bug, while bad identifies a commit containing the bug. These two references define the boundaries of Git's search range. You must know the status of both boundaries reliably.

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

In this example, the current commit is bad, while the revision tagged v1.2.0 is known to work.

Defining the search range

After you define both boundaries, Git checks out a commit within the range. Run the application or a relevant test to determine whether that revision contains the bug. Use git bisect bad if it does, or git bisect good if it does not.

git bisect good 4f8a2c1
git bisect bad 9d3e7b2

Git narrows the search range based on your results and selects the next revision.

Practice Search for a bug within a specific range

Start a bisect search. Mark the current commit as bad and the v2.0.0 tag as good. Write the commands in the correct order.

Starter code

terminal
# Aramayı başlat

# Mevcut commit hatalı

# v2.0.0 sürümü çalışıyor

Sample solution

terminal
git bisect start
git bisect bad HEAD
git bisect good v2.0.0

Expected output

Bisect session started.
Current commit marked bad.
v2.0.0 marked good.

Questions and answers

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

1 How do you tell bisect about an older commit where you verified that the bug is absent?

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

Explanation: git bisect good reports that the inspected commit works and does not contain the bug.

2 Mark a commit as bad

Question
git bisect ____
Answer
git bisect bad HEAD

Explanation: Use the bad reference to report that the current commit contains the bug.

3 Bisect references

Term Meaning
good Commit without the bug
bad Commit containing the bug
HEAD Reference to the current commit
Etiket Reference to a specific release

All lessons in Advanced