Discarding Changes
git restore file throws away working changes and git restore --staged unstages.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo oops >> a.txt
git restore a.txt
cat a.txt
echo more >> a.txt && git add a.txt
git restore --staged a.txt
git status -sResult
one M a.txt
Exercise
Discard changes.
git a.txt
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.