git reset

Move HEAD / reset index

high risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
Safer / dry-run alternatives
git stash push -u -m "backup"Stash before a hard reset
git reset --soft HEAD~1Keeps your changes
git revert <commit>Safe for pushed commits
What it does

Moves the current branch to another commit; --soft keeps changes staged, --mixed unstages, --hard discards.

Common flags
FlagMeaning
--soft --softKeep changes staged
--mixed --mixedKeep changes unstaged (default)
--hard --hardDiscard all changes⚠ Uncommitted work is lost permanently.
Examples
git reset --soft HEAD~1Undo the last commit, keep changes · explain & risk-check →
git reset HEAD fileUnstage a file · explain & risk-check →
Related
git reflog git revert git stash
Open the full explainer →More in Git

Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.