Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Rescue Your Lost Commits with Git Reflog

May 22, 2026

Ever accidentally hard-reset your branch or deleted a commit you desperately needed back? Don't panic just yet. Git rarely actually deletes anything immediately. It keeps a silent, behind-the-scenes diary of every single move you make called the "reflog."

By running `git reflog` in your terminal, you'll see a chronological list of all your recent actions, including checkouts, commits, and resets. Find the commit hash right before the disaster happened, run `git checkout [hash]` or `git reset --hard [hash]`, and just like that, you've traveled back in time to save your work.