Git Reflog
4 min read Quiz at the end
Reflog tracks every HEAD movement — use it to recover commits lost from accidental resets.
Git Reflog — Recover Lost Commits
# reflog tracks all HEAD movements
git reflog
# abc1234 HEAD@{0}: commit: feat: add login
# def5678 HEAD@{1}: checkout: moving from main to feature
# ghi9012 HEAD@{2}: merge: Merge pull request #5
# Recover from accidental reset
git reset --hard HEAD~3 # OOPS! deleted 3 commits
git reflog # find the commit before reset
git reset --hard abc1234 # restore to that commit
# Recover deleted branch
git reflog
git checkout -b recovered-branch abc1234
# Recover lost stash
git fsck --lost-found
git show abc1234
# Reflog expires after 90 days (default)
Topic Quiz · 1 questions
Test your understanding before moving on
1. What is the git reflog used for?
💡 Reflog records every HEAD movement — you can recover commits lost from hard resets.