git discard all unstaged changes
Quick Answer
# Discard all unstaged changes (current directory and below)
git restore .
# Discard changes in a specific file only
git restore src/app.ts
When to use this
You edited files but want to throw away the changes and revert to the last committed state.
Other causes & fixes
Old syntax (git < 2.23)
git checkout -- . # same as git restore .
git checkout -- src/app.ts # specific file
Discard staged changes (unstage + discard)
git restore --staged . # unstage all
git restore . # then discard unstaged
Preview what would be discarded first
git diff # shows unstaged changes before discarding
Related