Git Disaster Recovery - Getting Back What You Thought You Lost
The advanced rescue kit: recover 'lost' commits with the reflog, use rebase safely, and undo work you've already pushed - calmly, even at 2am.
Download EPUB- The Reflog - Your Safety Net The reflog is Git's private diary of everywhere HEAD has been; with it you can recover commits a bad reset --hard threw away, find work from a detached HEAD, and restore a deleted branch.
- Rebase Without Fear Rebase replays your commits onto a new base as brand-new commits; use it to keep history linear and tidy it before a PR, follow the one golden rule, and rescue a rebase gone wrong.
- Undoing What You've Already Pushed Once a commit is pushed others may have it; undo it safely with git revert on shared branches, and only rewrite pushed history on your own branch with --force-with-lease, never plain --force.