How to restore a lost file?


I accidentally deleted a 200 line file I spent a whole day working on. Instead of hitting copy I hit paste and lost everything. Any way to restore it? There isn’t an undo button.

Project name: amused-playground.
File: app/util/tictactoe.js

It was up to date about 5 minutes ago.


Ctrl-Z is undo, so you could have done that right after the mistake.

I restored the file for you.


Hey Tim, really sorry but I did it again. Could you reset to about 5 minutes back again? My undo is broken.

Thanks and sorry again.


Okay, it’s back again.


Are you on a Mac? In that case, it’s Cmd+Z.

For those who are interested in how I restored the file - there’s a Git repository built into every project, and you can run Git commands from the command line. I did a git log to look at the last few commits, and then git diff <hash> to look at the changes in each one. In this case, the second-last commit had the tictactoe.js with code in it, instead of the empty version. So I ran git checkout <hash> util/tictactoe.js to restore only that file to the earlier version, and then refresh to tell the editor to reload the file from disk.