Intermediate By Samson Tanimawo, PhD Published Sep 5, 2026 4 min read

git bisect & blame Cheat Sheet

"It worked on Tuesday." Bisect finds the commit. Blame finds the author. Log and reflog cover everything else. The git rescue commands you'll use during incidents, on one page.

bisect, the four steps

Binary search across commits. With 1,024 commits between known-good and known-bad, you'll test ~10 to find the culprit. Without bisect, you're testing them all.

bisect run, automated

If you can write a script that exits 0 for "good" and non-zero for "bad", git will drive bisect for you. The win is enormous: 30-second test × 10 commits = 5 minutes of you doing nothing.

blame, who and when

blame's defaults are noisy. The flags below cut through formatting changes and refactor commits to find the actual semantic author of a line.

log -p, what and why

blame tells you the commit; log -p shows the diff and the message that motivated it. The "why" is in the commit message; train your team to write good ones.

reflog, undoing the undoing

The reflog is git's safety net. Anything HEAD has ever pointed to is recoverable from here, even after a hard reset. It expires after 90 days by default.

stash recovery

Forgot what you stashed and dropped it? Still recoverable as long as gc hasn't run.