Git Recovery and Reflog

Git recovery patterns using reflog, ORIG_HEAD, fsck, dangling objects, and targeted reset or cherry-pick flows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Reflog Navigation

Read and use reflog entries to recover prior states.

Show reflog with dates

Display ref movements with timestamps.

bashANYreflog
bash
git reflog --date=iso

Pretty-print reflog as log

View reflog entries using log output.

bashANYrefloglog
bash
git log -g --oneline --decorate

Show previous HEAD

Inspect earlier HEAD position.

bashANYreflogrecovery
bash
git show HEAD@{1}

Create branch from reflog entry

Preserve a reflog-discovered commit.

bashANYreflogbranchrecovery
bash
git branch recovered HEAD@{3}

Reset to earlier HEAD

Restore prior branch tip exactly.

bashANYreflogresetdanger
bash
git reset --hard HEAD@{1}

Common Recovery Scenarios

Recover from reset, deleted branch, bad merge, and lost stash mistakes.

Recover after hard reset

Restore previous HEAD after disruptive operation when ORIG_HEAD is available.

bashANYrecoveryorig-head
bash
git reset --hard ORIG_HEAD

Recover deleted branch from reflog

Recreate a branch from recovered commit ID.

bashANYrecoverybranch
bash
git checkout -b recovered <dangling_or_reflog_commit>

Undo failed merge

Restore pre-merge state when merge --abort is unavailable.

bashANYrecoverymerge
bash
git reset --merge ORIG_HEAD

Find dropped stash commits

Locate dangling stash-like commits after accidental drop.

bashANYrecoverystashfsck
bash
git fsck --no-reflog | grep dangling

Cherry-pick recovered commit

Apply recovered work onto a clean branch.

bashANYrecoverycherry-pick
bash
git cherry-pick <recovered_commit_sha>

Dangling Objects and Inspection

Find unreferenced commits, blobs, and trees.

Check repository integrity

Validate objects and refs.

bashANYfsckintegrity
bash
git fsck --full

List dangling objects

Find unreferenced commits, trees, and blobs.

bashANYfsckdangling
bash
git fsck --full --dangling

Inspect dangling commit

Review commit content before recovery.

bashANYfsckshow
bash
git show <dangling_commit_sha>

Inspect dangling blob

Print blob content if a file was lost.

bashANYfsckblob
bash
git cat-file -p <blob_sha>