Lesson 19 / 28
git reset: soft, mixed, hard
Move a branch backward with git reset --soft, --mixed and --hard and know how much each one discards.
The three flavors
--soft keeps changes staged, --mixed (default) keeps them unstaged, --hard discards them entirely.
git reset --soft HEAD~1 # undo commit, keep changes staged
git reset HEAD~1 # undo commit, keep changes unstaged
git reset --hard HEAD~1 # undo commit AND discard changes--hard is destructive
git reset --hard permanently deletes uncommitted work. Double-check git status before running it — there's no confirmation prompt.
Quick check: Which reset mode discards changes entirely?
- --soft
- --hard
- --mixed
- --keep
Answer
--hard — --hard resets both the commit history and the working directory, deleting uncommitted work.