Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Rescuing "Lost" Commits with Git Reflog
March 15, 2026
Ever accidentally hard-reset your branch or deleted a commit you actually needed? Don't panic! Git keeps a secret log of every time your HEAD moves, called the 'reflog'. By running `git reflog` in your terminal, you can see a history of where your branch has been, even if those commits are no longer visible in your standard logs.
Once you find the SHA of the lost commit in the list, you can simply `git checkout` that hash or `git merge` it back into your current branch. It is essentially a local safety net for those moments when you think you've accidentally wiped out hours of work.