Recovery

Git Recovery Channel

Turn common Git mistakes into focused rescue guides covering reset, rebase, deleted branches, detached HEAD, and reflog-first recovery.

Recovery

Start Here First

Build a reflog-first recovery habit first, then work through reset, rebase, deleted-branch, and detached-HEAD incidents.

Recovery

Representative Topics

If you only read three first, start with reflog, reset recovery, and how to get back to control after a bad pull.

Recovery

Recovery Topics

Split “what do I do now?” recovery situations into direct, actionable rescue guides instead of one abstract article.

Recovering with reflog

Use reflog to locate previous references and recover from reset, rebase, or lost branch states.

Recover after an over-aggressive reset

When reset moves the branch, index, or working tree farther than expected, first identify which layer changed, then recover with reflog, ORIG_HEAD, or a rescue branch.

Recover after a bad rebase

When rebase introduces conflicts, missing commits, or a result you no longer trust, stop rewriting history and recover control with abort, reflog, and rescue branches.

Recover a deleted branch

When a branch disappears, first determine whether only the name is gone or whether the commits have become hard to reach, then restore it from reflog or another surviving reference.

Rescue work from detached HEAD

Detached HEAD is not an error by itself. The real risk is creating commits there and leaving them without a branch name that preserves them.

Undo after a pull you regret

When a pull leaves your branch in an unexpected state, first determine what pull actually did, then recover with ORIG_HEAD, reflog, or a rescue branch.

Assess the impact after a force push

After a force push, the urgent task is not another push. First identify which refs were replaced, who may still depend on the old history, and what recovery window still exists.

Recover a lost stash

When stash entries seem to disappear, determine whether they were popped, dropped, or detached from refs, then recover via reflog or dangling commits.

Recover after a wrong cherry-pick

If the wrong commit was cherry-picked, choose reset or revert based on whether the history is already shared, then replay the correct patch sequence.

Recover after an accidental merge

When the wrong branch was merged, decide between reset and revert -m based on sharing state, and undo the merge safely without damaging collaboration history.

Recover after an accidental git clean

After `git clean` removes untracked files, recovery usually depends on external history sources; prevent recurrence with dry-run and stash -u safeguards.

How to recover from a failed cherry-pick

Complete recovery workflow when cherry-pick encounters conflicts, gets aborted, or produces unexpected results. Covers --abort, --continue, --skip, and post-cherry-pick remediation.

How to undo a merge commit

Correct methods for undoing a merge commit when things go wrong. Deep dive into git revert -m and the parent numbering system, plus common pitfalls.

Recovering from a broken interactive rebase

Common errors during interactive rebase (wrong actions, conflicts, editor issues) and how to recover, including --abort, --edit-todo, and reflog-based recovery.

Recovering lost commits

Recovery strategies for 'lost' commits across scenarios: detached HEAD commits, post-filter-branch, deleted branches, and over-reset. Core tools are reflog and fsck.

Recovering from a corrupted repository

Diagnosis and recovery strategies for repository corruption: damaged pack files, missing objects, and disk failures. Covers git fsck, remote re-clone, pack recovery, backup restoration, and prevention.

Recovering commits made in detached HEAD

How to properly recover commits made in detached HEAD state back to a branch. Covers creating new branches, merging into existing branches, and prevention strategies.

Fixing wrong author or commit message after commit

How to fix wrong author info, commit messages, or forgotten files after committing. Covers amend, interactive rebase, and batch author modification with filter-repo.