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

Git Blame & Archaeology

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

Closest to 'only careful code review or runtime testing' (d7). The detection_hints indicate automated detection is 'no' and the signals are qualitative — non-obvious code without blame context, orphaned code, code owned by someone who left. Tools listed (git, github, gitlab) require deliberate human investigation; no automated linter or SAST will flag that git blame wasn't consulted or was misread.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix describes adding flags like -w for whitespace and using git log -S for pickaxe search — these are minor workflow adjustments rather than a one-line code patch, but they are contained, low-cost corrections to how the tool is invoked rather than multi-file refactors.

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

Closest to 'minimal commitment' (b1). Git blame and archaeology are investigative workflow tools, not structural code choices. Using or not using them imposes no persistent architectural tax on the codebase itself; each use is isolated and doesn't shape future maintainer decisions beyond good documentation habits.

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

Closest to 'notable trap' (t5). The misconception field directly names the canonical trap: developers assume git blame is for assigning fault rather than understanding context, leading to blame culture rather than learning. This is a well-documented gotcha (even the command name reinforces the wrong mental model), but experienced developers eventually learn the correct intent.

About DEBT scoring →

Also Known As

git blame git bisect git log -S code archaeology

TL;DR

Using git blame, git log -S, and git bisect to trace when code was introduced, who wrote it, and which commit caused a bug — essential for debugging and context.

Explanation

git blame file.php shows the last commit and author for each line — useful for context on why code exists. git log -S 'string' finds commits where the string was added or removed (pickaxe search) — answers 'when was this function added?'. git log --follow -p file traces the history of a file including renames. git bisect binary-searches commit history to find the first bad commit introducing a bug. git annotate is an alias for blame with more context. Combining these tools turns git history into comprehensive documentation.

Common Misconception

git blame identifies who to blame for bugs — git blame identifies who to ask for context; the goal is understanding why code exists, not assigning fault.

Why It Matters

A mysterious security check with no comment makes sense instantly with git blame — the commit message explains the vulnerability it prevents and links to the issue, avoiding future removal.

Common Mistakes

  • git blame showing a formatting commit — use -w to ignore whitespace changes.
  • Not using git bisect for regressions — manually checking 50 commits is hours; bisect finds the culprit in 6 steps.
  • Assuming the blamed commit explains everything — the PR or issue linked from the commit message has more context.
  • Not using git log --follow for renamed files — plain git log stops at the rename.

Code Examples

✗ Vulnerable
# Manual regression hunt — slow:
# Bug appeared 'sometime in the last month'
# Check commit from 30 days ago: bug present? No
# Check commit from 20 days ago: present? No
# Check commit from 10 days ago: present? Yes
# ...
# 2 hours later: found the commit
✓ Fixed
# git bisect — binary search, 6 steps for 64 commits:
git bisect start
git bisect bad HEAD          # Current commit has the bug
git bisect good v1.5.0       # This tag was fine
# git checks out the middle commit:
git bisect good              # No bug here — move to upper half
git bisect bad               # Bug here — narrow further
# ... 4 more steps
# Result: 'abc1234 is the first bad commit'
git bisect reset

# Find when a function was added:
git log -S 'processPayment' --oneline
# Show full history of a file:
git log --follow -p -- src/Payment/Gateway.php

Added 16 Mar 2026
Edited 22 Mar 2026
Views 55
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 1 ping S 3 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 3 pings S 0 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 13 Perplexity 9 Ahrefs 5 Google 4 SEMrush 4 Scrapy 4 ChatGPT 2 Majestic 1 Claude 1 Meta AI 1 Sogou 1 PetalBot 1
crawler 42 crawler_json 4
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Low
⚡ Quick Fix
Use git blame -w (ignore whitespace) and git log -S 'search_term' (pickaxe) to understand why code exists — the commit message and linked issue give context that the code itself cannot
📦 Applies To
git any
🔗 Prerequisites
🔍 Detection Hints
Non-obvious code without blame context; orphaned code with no linked issue or PR; code owned by someone who left the team
Auto-detectable: ✗ No git github gitlab
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Low Context: File


✓ schema.org compliant