Recover with Reflog in Git

From the Git cheat sheet · Fixing Mistakes · verified Jul 2026

Recover with Reflog

Find and recover commits that look "lost" after rewrites

bash
# Show the reflog (HEAD movement history)
git reflog
git reflog --all          # All refs, not just HEAD

# Entries look like:
# abc1234 HEAD@{0}: rebase finished
# def5678 HEAD@{1}: commit: WIP fix
# 0123abc HEAD@{2}: checkout: moving to main

# Recover by SHA or HEAD@{n}
git reset --hard HEAD@{1}
git reset --hard <sha>

# Safer: branch off the recovered commit
git switch -c recovery HEAD@{1}
💡 Reflog records every HEAD movement — your safety net for rewrites
✅ Almost nothing is truly lost for ~90 days
⚡ Use HEAD@{n} or time syntax (HEAD@{2.days.ago})
🔧 Branch off the recovered commit instead of reset --hard

More Git tasks

Back to the full Git cheat sheet