Discard all local changes
Destructive
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Throws away every uncommitted change in tracked files, returning the working tree to the state of the last commit.
gitdiscardworking-tree
Confirmation required
This recipe is destructive and requires confirmation — confirm you understand the impact before running any command below.
Commands
Review exactly which changes will be discarded
git status --shortUnstage everything so all changes are visible to the next step
git restore --staged .Discard all uncommitted changes in tracked files
git restore .Verification
git status --shortNo modified tracked files remain; only untracked files may still be listed.
Undo
Not undoable
Discarded changes were never committed and cannot be recovered by git. Use git stash instead when the changes might be needed later.
Pitfalls
- Untracked files are not touched; use the clean untracked files recipe to remove them.
- Consider git stash first — it discards nothing and can be restored later.