Recover lost work safely with Git
8 steps · about 4 h 10 min · Intermediate
- Record the current state (reference, Git documentation, 25 min)
Separate staged, unstaged and untracked work before attempting recovery.
- Create a safety branch (reference, Git documentation, 25 min)
Give the current commit a durable name before changing pointers or restoring content.
- Inspect the visible history (reference, Git documentation, 30 min)
Understand commit identity, ancestry and decorations before deciding what is actually missing.
- Find moved references (reference, Git documentation, 35 min)
Locate commits previously named by HEAD or a branch after a reset, rebase or deletion.
- Recover selected files (reference, Git documentation, 30 min)
Restore worktree or index content from an explicit source without moving branch history.
- Reapply a lost commit (reference, Git documentation, 35 min)
Copy a known change onto the safety branch while keeping the original object available.
- Undo a published change (reference, Git documentation, 35 min)
Create a new inverse commit when rewriting shared history would disrupt collaborators.
- Verify objects and the final graph (reference, Git documentation, 35 min)
Check repository connectivity and review the resulting branches and commits before pushing.