⏱️ CHAPTER · GIT REFLOG
Chef You

The Ultimate
Safety Net

Accidentally deleted a branch? Used reset --hard? Don't panic. reflog remembers everything HEAD ever pointed to — even things git log can't see anymore.

Scene I

The disaster strikes

Chef You

You ran git reset --hard HEAD~3 and wiped out your last 3 commits. They've vanished from git log.

But Git's reflog — the reference log — recorded every move HEAD made. Those "lost" commits are still there. You just need to find them in the reflog and rescue them with git reset --hard HEAD@{n}.

⏱️ REFLOG RESCUE Find the entry BEFORE the reset and click it
💥
DISASTER: git reset --hard HEAD~3
3 commits are "gone" from git log. Find the right reflog entry to recover them.
git reflogclick to rescue
Rescued!

🎉 Commits recovered

The reflog saved your work. Nothing is truly lost in Git as long as it was committed. The reflog keeps entries for about 90 days, giving you plenty of time to recover.

Reflog records: commits, resets, rebases, checkouts, merges — every move HEAD makes.

$ git reflog
a1b2c3d HEAD@{0}: reset: moving to HEAD~3
e7b2d18 HEAD@{1}: commit: Add glaze recipe
$ git reset --hard HEAD@{1}
HEAD is now at e7b2d18 Add glaze recipe ✓
Epilogue
Reflog is Git's black box recorder.
Nothing committed is truly lost.
Recovery is always possible.

Remember: reflog is local only. It's not pushed to the remote. Your safety net lives on your machine.