DEV Community

Toolloom
Toolloom

Posted on • Originally published at toolloom.com on

Saving Yourself with Git Reflog

We've all been there: you run a destructive command like git reset --hard or accidentally delete a branch, and panic sets in. Before you accept defeat, remember that Git rarely actually deletes anything immediately. It keeps a secret history of every single action you take locally in a tool called the reflog.

Just type git reflog in your terminal to see a list of your recent movements, even the ones you thought you lost. Once you find the commit hash from right before your mistake, you can run git reset --hard to bring your code back from the dead. It's the ultimate undo button for Git.

Top comments (0)