Recover lost work safely with Git

8 steps · about 4 h 10 min · Intermediate

  1. Record the current state (reference, Git documentation, 25 min)

    Separate staged, unstaged and untracked work before attempting recovery.

  2. Create a safety branch (reference, Git documentation, 25 min)

    Give the current commit a durable name before changing pointers or restoring content.

  3. Inspect the visible history (reference, Git documentation, 30 min)

    Understand commit identity, ancestry and decorations before deciding what is actually missing.

  4. Find moved references (reference, Git documentation, 35 min)

    Locate commits previously named by HEAD or a branch after a reset, rebase or deletion.

  5. Recover selected files (reference, Git documentation, 30 min)

    Restore worktree or index content from an explicit source without moving branch history.

  6. Reapply a lost commit (reference, Git documentation, 35 min)

    Copy a known change onto the safety branch while keeping the original object available.

  7. Undo a published change (reference, Git documentation, 35 min)

    Create a new inverse commit when rewriting shared history would disrupt collaborators.

  8. Verify objects and the final graph (reference, Git documentation, 35 min)

    Check repository connectivity and review the resulting branches and commits before pushing.