reset --hard
--hard moves the branch and resets files. It destroys uncommitted work.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'second'
echo scratch >> a.txt
git reset -q --hard HEAD~1
cat a.txt
git log --oneline | wc -lResult
one 1
Exercise
Discard everything.
git reset HEAD
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.