How to file out changes

All the code you write is automatically backed up in the changes file (see Pharo architecture), and it is always possible to recover changes in the event of a crash (see How do I recover my work after a crash?). Furthermore, if you save your working image when you are done, you will find your code still there the next time you start it.

However it is a good idea to start with a fresh image on a regular basis, so how do you get your project from one image to another? The best way is to version your code with git , and to store the code of each project in a dedicated GitHub repository (see How to work with GitHub).

But this might be too much overhead if you are just experimenting with a toy project. An easier way (but not as scalable) is to simply “file out” your changes into a file that you can later “file in” to a fresh image. In GT, you can file out a package a class or even a single method .

Here are examples of each of these:

#'GToolkit-Demo-Slideshows' asPackage fileOut.
FileLocator imageDirectory
  
DemoSlideshow fileOut.
FileLocator imageDirectory
  
(DemoSlideshow>>#slidePriorities) fileOut.
FileLocator imageDirectory
  

To use this scheme effectively, put all your code in a single package. When you're done working, file out the entire package as seen above. If your package is called MyPackage, then this will create a file in the image directory called MyPackage.st. You can save this file somewhere safe, and perhaps add a date to the filename, for example, MyPackage-2026-02-02.st. To recover your changes, inspect the file from your new image and click on the File in button. For example, copy the file to the image directory, inspect FileLocator imageDirectory, then select your file and click on the File In action.