Elena' s AI Blog

Debugging Git Commits: Finding Exactly What Broke

12 Jul 2026 (updated: 24 Aug 2026) / 12 minutes to read

Elena Daehnhardt


Matrix fell, Midjourney Nov 2023


TL;DR:
  • Use git log, git show, and git diff to isolate regressions. Create a safety branch first, then merge or cherry-pick only what you need.

Previous: Part 6 โ€” Git Log

Next: Part 9 โ€” Reverting Commits in GitHub

Comparing Git Commits to Debug a Regression

A feature worked yesterday. Itโ€™s broken today. I donโ€™t guess when this happens โ€” I compare the two commit states directly and let Git tell me exactly what changed. Commit comparison is the practice of diffing two points in a repositoryโ€™s history to isolate which commit introduced a regression. Hereโ€™s the workflow I actually use: pick a good and a bad commit, diff them precisely, and recover only what you need without dragging the rest along with it.


Step 1: Identify the Commit Range with git log

Start with the shape of your history:

git log --oneline --decorate --graph

From that graph, pick two points:

  • GOOD_COMMIT โ€” the last commit you know worked.
  • BAD_COMMIT โ€” the first commit where things broke.

Everything else in this workflow hangs off those two references.

The commit range between GOOD_COMMIT and BAD_COMMIT GOOD_COMMIT..BAD_COMMIT commit GOOD_COMMIT commit BAD_COMMIT commit last known good first broken

The range GOOD_COMMIT..BAD_COMMIT covers every commit in between โ€” thatโ€™s what git diff, git log -p, and the recovery commands in the next steps all operate on.


Step 2: Compare Commit States with git diff and git show

git diff is a Git command that compares two references โ€” commits, branches, or the working tree โ€” and prints the line-by-line changes between them. Once you have your range, git diff shows you exactly what changed:

git diff GOOD_COMMIT..BAD_COMMIT

Narrow it to one file when you already suspect where the regression lives:

git diff GOOD_COMMIT..BAD_COMMIT -- path/to/file.py

git show is a Git command that displays a single commitโ€™s metadata (author, date, message) together with its full patch. When you want the full picture on the bad commit in one go, git show gives you that:

git show BAD_COMMIT

Step 3: Inspect the History in the Range with git log -p

A diff tells you what changed overall, but sometimes you need it commit by commit. git log is a Git command that lists commits reachable from a given range; with -p, it also prints each commitโ€™s patch:

git log --oneline GOOD_COMMIT..BAD_COMMIT
git log -p GOOD_COMMIT..BAD_COMMIT

The first command gives you a quick list of suspects. The second shows the actual patch for each one, so you can spot which commit introduced the regression rather than just knowing it happened somewhere in the range.

Step 4: Create a Safety Branch Before Recovery

๐Ÿ”’ Subscribe to keep reading.

Step 5: Recover Good Changes with git cherry-pick or git revert

๐Ÿ”’ Subscribe to keep reading.

Step 6: Resolve Merge Conflicts During Cherry-pick or Revert

๐Ÿ”’ Subscribe to keep reading.

Mental Model: Commits as Before-and-After Photographs

๐Ÿ”’ Subscribe to keep reading.

Checklist for Debugging a Regression by Comparing Commits

๐Ÿ”’ Subscribe to keep reading.

Summary: Debugging Git Regressions by Comparing Commits

๐Ÿ”’ Subscribe to keep reading.

References

๐Ÿ”’ Subscribe to keep reading.

Subscribe to unlock the full article โค๏ธ

I keep most of the site completely open. A few unusually detailed tutorials need a free subscriber login so I can keep publishing this kind of work.

The form below signs you up for the newsletter. It does not log you into the app โ€” log in afterwards (same email) to unlock this article and download your subscriber gifts. New subscribers get an inbox mail: Set a password to unlock articles.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.



Citation
Elena Daehnhardt. (2026) 'Debugging Git Commits: Finding Exactly What Broke', daehnhardt.com, 12 July 2026. Available at: https://daehnhardt.com/blog/2026/07/12/git-commit-differences/
All Posts