Skip to main content
Back to command reference
Inspecting History

git reflog

Show the reference log — your safety net for lost commits

Practical example

bash
git reflog
# abc1234 HEAD@{0}: commit: Fix login bug
# def5678 HEAD@{1}: reset: moving to HEAD~1
# Recover: git branch recovered-branch abc1234

Command overview & how it works

Records every movement of HEAD — every checkout, commit, reset, rebase, and merge. When you accidentally lose commits (from a hard reset, rebase gone wrong, or deleted branch), the reflog is your recovery tool. Each entry shows the operation, the previous position, and how HEAD moved. Use git reflog to find the commit hash of a lost state, then git checkout <hash> or git branch <name> <hash> to recover it. The reflog is local — it is not shared with remotes and is not backed up. Entries expire after 90 days (for reachable commits) or 30 days (for unreachable). Use git reflog show <branch-name> to see the reflog for a specific branch. The reflog is why Git is hard to permanently lose data from.

Chapter 07 · Disaster Recovery Drills

Disaster-proof your Git workflow with the Field Guide

Learn how to rescue deleted branches, revive detached HEADs, and undo bad rebases without panic. 97-page PDF + ePub — ₹499.

Learn more

Practical tips

  • Check git reflog first whenever a reset or rebase 'loses' work — your commits are usually still recoverable.
  • The reflog is local to your machine and not shared with remotes, so push important branches early.
  • Recreate a deleted branch with git branch <name> <hash> using the hash you find in the reflog.

Deep-dive guides & tutorials

In-depth walkthroughs and practical scenarios related to git reflog

All guides →

Related commands

More from Inspecting History