Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Saved by the Git Reflog
May 21, 2026
Ever accidentally hard-reset your branch or deleted a commit you desperately needed back? Before you panic and start rewriting code from memory, meet `git reflog`. Think of it as Git's safety net—it records every single movement of your HEAD, even the ones that aren't part of your commit history anymore.
Just run `git reflog` in your terminal to see a chronological list of your recent actions. Once you find the commit hash where your lost code still existed, you can bring it back to life using `git checkout <commit-hash>` or cherry-pick it back into your current branch. It's an absolute lifesaver.