Lesson 18 / 26

Discarding File Changes

git restore to throw away uncommitted edits.

Restore a file

Reverts a file in the working directory back to its last committed state — destructive, uncommitted edits are gone.

git restore config.js
# older equivalent:
git checkout -- config.js

Unstage a file

Moves a file back from staged to unstaged without touching its content.

git restore --staged config.js