Is there a way to restore previous Google Apps Script Editor Versions

3.7k Views Asked by At

Is there a way to restore previous Google Apps Script Editor Versions?

I accidentally deleted a big portion of my code in the Google Script Editor. In the new editor, I do not see a way to restore versions.

In the old editor, I can go to File > See version history (please see image)enter image description here.

Unfortunately, this only goes back a few hours.

Is there a way to retrieve a version from yesterday?

TIA

2

There are 2 best solutions below

4
Jason E. On

You can try reverting to the legacy editor to access your script revision by clicking on the "Use legacy editor" button on the top right of the Apps Script window.

enter image description here

0
John Pankowicz On

Even if you weren't already using clasp, when you created those versions, you can still use it now to retrieve the code for them. However, this only works if you created an explicit version of the code, under deployments, even if you didn't actually deploy them.

First install NPM, then:

npm i @google/clasp -g             # install clasp
clasp login                        # login to your Google account
mkdir some_folder
cd some_folder
clasp clone <ScriptId>             # replace <ScriptID> with your script id
clasp pull --versionNumber X       # replace X with version number you want