How do you undo "Discard all changes" in VS Code/Git
After accidently pressed discard changes btn on the wrong file, and I ended up here) Having not found the way to restore, I have tried simple CMD+Z (CTRL+Z) in that file, and boom - everything is back, so dont give up and try that :) Very pleased
That's horrible, But I got some luck!!
I was able to recover the files, where I clicked, discard all changes
.
No doubt, git has no option to recover those lost changes, but our system (and VScode has).
How I recovered those changes?
- I just opened those files again in VScode, using
ctrl+p
. - Once opened, then I pressed
ctrl+z
to try undo my changes, and guess what, My system's clipboard help me recover all of my exact changes.
If you were working on a new file, that's now deleted and have no footprint now. Still you can recover the file, simply by pressing
ctrl+p
, coz file was already opened in VScode, with label(deleted)
.
In short, you can still recover your changes, provided you haven't restarted your VScode.