Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Rescuing Your Code with Git Reflog
February 23, 2026
Ever accidentally deleted a branch or performed a hard reset that wiped out work you weren't ready to lose? Don't panic just yet. Git keeps a secret log of every single move you make locally called the 'reflog'. By running `git reflog`, you can see a history of where your HEAD has been, including commits that are no longer part of any visible branch.
Once you find the SHA of the lost commit, you can simply run `git checkout [SHA]` or `git merge [SHA]` to bring your work back from the dead. It's like an ultimate 'undo' button for when you've strayed too far into the terminal weeds.