← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Git Bisect

Git 1.7.14 Intermediate
debt(d7/e3/b3/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The common mistakes — not resetting after bisect, marking commits incorrectly, lacking a reproducible test — are not caught by any listed tool (git, phpunit, pest) automatically. Git itself won't warn you that you left a detached HEAD state after bisect, or that you poisoned the search with an unrelated failure. Only careful manual review or noticing unexpected repo state at a later point surfaces these issues.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix describes running a small sequence of git commands (git bisect start, mark good/bad, git bisect run). Correcting a mistake like an unclean bisect state or a poisoned search requires restarting the process — a modest but contained effort within one workflow, not spanning multiple files or components.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3). Git bisect is a debugging technique invoked episodically; it doesn't impose ongoing structural weight on the codebase. The main burden is ensuring a reproducible test exists and remembering to run git bisect reset, which is a localised procedural tax rather than a codebase-wide commitment.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap (a documented gotcha most devs eventually learn)' (t5). The misconception field identifies the trap as thinking you need programming history expertise, when in fact you only need a reproducible test. Additional traps include forgetting git bisect reset (leaving detached HEAD), and poisoning the binary search with unrelated failures — documented gotchas that intermediate developers encounter and eventually learn, but not immediately obvious.

About DEBT scoring →

Also Known As

git binary search bisect

TL;DR

A binary search tool that finds the commit that introduced a bug by marking commits as good or bad — locating the culprit in O(log n) steps.

Explanation

git bisect automates a binary search through commit history. You mark a known-good commit and a known-bad commit, then git checks out the midpoint. You test and mark it good or bad, halving the search space each time. For 1000 commits, this finds the culprit in ~10 steps. With git bisect run, you automate the test — bisect runs your test suite and marks commits automatically, making regression hunting fully automated.

Diagram

flowchart TD
    START[git bisect start] --> BAD[git bisect bad HEAD<br/>current commit has bug]
    BAD --> GOOD[git bisect good v1.0<br/>this tag was fine]
    GOOD --> MID[Git checks out midpoint]
    MID --> TEST{Test: bug present?}
    TEST -->|yes - git bisect bad| NARROW1[Narrow to upper half]
    TEST -->|no - git bisect good| NARROW2[Narrow to lower half]
    NARROW1 & NARROW2 --> MID
    MID -->|after log2 N steps| FOUND[First bad commit identified]
    FOUND --> RESET[git bisect reset]
    INFO[64 commits = 6 steps<br/>1000 commits = 10 steps]
style FOUND fill:#238636,color:#fff
style INFO fill:#1f6feb,color:#fff

Common Misconception

You need to know programming history to use git bisect — you only need a reproducible test; git bisect run handles the rest automatically.

Why It Matters

Without bisect, finding a regression in 500 commits requires manual investigation; bisect finds it in 9 steps — transforming hours of debugging into minutes.

Common Mistakes

  • Not having a reproducible test before starting bisect — manual marking requires re-testing at each step.
  • Marking a commit as bad when it has an unrelated test failure — poisons the search.
  • Not running git bisect reset after finishing — leaves the repo in detached HEAD state.
  • Not using git bisect run with an automated test — missing the most powerful feature.

Code Examples

✗ Vulnerable
# Manual bisect — slow without automation:
git bisect start
git bisect bad HEAD
git bisect good v1.2.0
# Git checks out commit — developer manually runs app and marks
git bisect bad  # or good
# Repeat 10 times manually...
✓ Fixed
# Automated bisect with test script:
git bisect start
git bisect bad HEAD
git bisect good v1.2.0

# test.sh exits 0 = good, non-zero = bad:
git bisect run ./test.sh
# Git runs binary search automatically — finds the commit
git bisect reset  # Return to original HEAD

Added 15 Mar 2026
Edited 22 Mar 2026
Views 65
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W 0 pings T 2 pings F 1 ping S 5 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 18 Perplexity 8 Scrapy 8 Ahrefs 5 SEMrush 5 Google 3 ChatGPT 3 Claude 2 Majestic 1 Meta AI 1 PetalBot 1
crawler 51 crawler_json 4
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Low
⚡ Quick Fix
Run git bisect start, mark the current broken commit as bad and a known good commit as good, then git bisect run vendor/bin/phpunit to automate finding the regression
📦 Applies To
git 1.7.14 any
🔗 Prerequisites
🔍 Detection Hints
Bug regression that appeared at some unknown point in history; manually reviewing commits to find cause
Auto-detectable: ✓ Yes git phpunit pest
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Low Context: File


✓ schema.org compliant