Reset: Soft, Mixed and Hard
--soft moves the branch only. --mixed (default) also unstages. --hard also resets files. Hard resets destroy uncommitted work.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'Second'
git reset --soft HEAD~1
git status --short
git reset -q
git status --short
git reset -q --hard
cat a.txtResult
M a.txt M a.txt one
Exercise
Keep changes staged.
git reset HEAD~1
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.