Discard local changes to a file
Destructive: deletes work
Short answer
Run git restore <file>. The file goes back to its last committed (or staged) version.
Your uncommitted edits to that file are gone for good: they were never committed, so Git can't bring them back. Check them with git diff <file> first.
The commands, one by one
- 1
git diff bread.txtLook at what you're about to throw away (lines starting with
+are yours). - 2
git restore bread.txtReplaces the file with its last committed version. Other files aren't touched.
For your own repository: Use your own file name.