Recover Lost Work With git reflog
Find and restore commits after an accidental reset, rebase or branch delete.
Run git reflog to list recent HEAD positions, then reset or cherry-pick the commit you need.
01Command
Command
$ git reflog02What it does
The reflog is a local journal of every ref movement, including commits no longer reachable from a branch. It is the safety net that makes command-line history editing safe, and it has no repository UI equivalent for recovering detached or discarded commits.
03Risk
!Warning: Reflog entries expire after the default retention period, so recover quickly and copy the SHA somewhere safe.
04Undo
Undo
$ git reset --hard HEAD@{1}05Sources
- git-reflog documentationEvidence: Documents the reflog, which records where HEAD and branches have pointed.
Last verified: 2026-10-13 · Category: Developer
06Related solutions
List Local Time Machine Snapshots with tmutil
See every local APFS Time Machine snapshot on your startup disk and delete ones you no longer need.
Clone Folders with Full macOS Metadata Using ditto
The copy command that keeps Finder flags, ACLs, resource forks, and exact permissions intact.
Export and Import Preference Domains with defaults
Snapshot an entire app's settings to a plist file, then restore or migrate it later.