Git · History and recovery

git restore

Discards working-tree changes for a path, or restores a staged file with --staged. Be certain before running it.

Syntax
git restore <path>

Example

Example
git restore src/app.ts
git restore --staged src/app.ts

More in this group

git clean git reflog git reset --hard git reset --mixed git reset --soft git revert git stash git stash apply vs pop

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course