Tsallaka zuwa abun ciki
Justice Tech School

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 -s

Result

one
 M a.txt

Exercise

Discard changes.

git  a.txt

Quiz Test

Can restore be undone?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.