Save a recovery pointer before hard reset or risky history edits.
Section: Decision Guide
Create a safety branch before destructive changes
bash
bash
git branch backup-before-resetExplanation
A simple but strong safeguard before destructive operations like hard reset or forceful history rewriting.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Decision Guide
Use reflog after a mistaken reset
Find the previous branch tip after a bad reset.
Mental model for reset vs restore vs revert
Quick decision guide for the three similarly named commands.
Reset out of a conflicted merge state
Try to leave local changes intact while backing out of a merge-like operation.
Undo last commit but keep everything staged
Move HEAD back one commit while preserving index and working tree.
Revert a single commit
Create a new commit that reverses an earlier commit.
Discard unstaged changes in a file
Restore a file in the working tree from the index.