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.

1 Like

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.

1 Like

Hey Tim, i dont know if this will work or if you’ll see this but can you restore deleted files from glitch?

Hey there @lisxpereira, welcome to the Glitch community! In the future, please don’t bump old posts, instead you can create a new post with your question.

As for the question you asked, there is now a rewind feature. You can go to the tools section, then on top there should be a rewind button which you can click to restore a deleted file from your project.

help!!! I deleted a file name ar.html by mistake !!! Can you restore it??
I can see it with the rewind tool but cannot copy it!!!

Sorry for that… you save my life!!! File recovered!!! Yes!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.