How to undo a git restore to get back changes

If the file you accidentally restored is currently open in your Text Editor or IDE, a simply Undo operation would do the trick and get you your changes back.

I accidentally typed git restore . while I only wanted to restore one file. Luckily for me, all the files that had been restored by the command were still open in VSCode, where I made the changes, so executing an Undo in each of those files did the trick for me and I got my changes back.

Leave a Comment