2

I have made some codes in a newer version of my library through Google Scripts. However, I want to revert back to a previous version of the library and make edits of that.

For example: I have 24 versions and want to go back to version 16 for editing, how do I do that without deleting version 17 to 24. The newer versions were used for tests and some of the codes do not work as much as I want to but I want to still keep it to debug.

Thanks for any possible solutions!

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
stacieleap
  • 21
  • 1
  • 2
  • 1
    For those still looking at this, check out [this thread](http://stackoverflow.com/questions/33904174/how-do-i-download-previous-saved-revisions-of-a-google-apps-script) – kgingeri Apr 03 '17 at 19:18

2 Answers2

4

Using timestamp information, you can select the Revision that corresponds to the Version you want to restore for editing.

Explanation

There are two mechanisms used for version management in Google Apps Script, both accessible under the "File" menu.

  • Revision History - this is equivalent to an "auto-save" feature in a text editor. Revisions are saved frequently, and timestamped. There is a facility to select past revisions and restore them.

  • Manage Versions - to support library development (your case) and script publication, you can create numbered versions of your script. While you can select specific versions to publish or include as a library, and delete saved versions, there is no facility that supports reversion of the most current script content to a previous version.

Screenshot - file menu

Example

This example illustrates the idea. Normally, your Versions would be much further apart in time than in this example.

Screenshot - Script Versions

Screenshot - file Revision History

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • If there was a reward for the *clearest answer on StO* you would deserve it.... that's clear too! +1 again... my number 1 all time ranking is getting fragile :-) keep on! – Serge insas Jun 20 '13 at 18:51
  • As @BryanP points out in his answer, this isn't exact. It's best if you develop the discipline to save important versions of your code outside of Google's infrastructure. (I keep zipped versions of projects in git, for example.) There are also parts of your script that aren't revision controlled, and can be lost; see [this question](http://stackoverflow.com/questions/14385008/backing-up-gapps-source). This question, however, asks about code that already exists, so barring access to the Tardis it's too late to go back and save the old version. – Mogsdad Jun 21 '13 at 09:41
1

The file Revision history doesn't correspond to a project Version. In Mogsdad's example, how do we know the 38:34 time wasn't where we saved v1?

I typically get in the habit of saving a new copy of the entire script file right after saving a new version, then copying and pasting code from old files that were renamed to the version I saved them at over the working file if I ever need to revert back to the exact way the code was at the time of a past version. Guess there could be a restore-code-to-saved-version option that would make the whole process better.

There was also just a demo done today that could be useful in working with your own version control.

Bryan P
  • 5,031
  • 3
  • 30
  • 44