Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Lost your commits? Git reflog to the rescue!

May 28, 2026

We've all been there: you perform a force push, a messy rebase, or accidentally delete a local branch, and suddenly your hard work seems gone forever. Before you panic, run `git reflog` in your terminal. Git keeps a silent, chronological diary of almost every action you take locally, even if those commits are no longer attached to any active branch.

Once you find the commit hash of your lost work in the reflog list, you can easily resurrect it by running `git checkout <commit-hash>` or creating a new branch from that point. It's the ultimate safety net that will save your skin more than once.