reset --soft and --mixed
--soft moves the branch and keeps changes staged. --mixed also unstages.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'second'
git reset -q --soft HEAD~1
git status -s
git reset -q
git status -sResult
M a.txt M a.txt
Exercise
Keep 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.