Skip to main content

The PreTeXt Guide

Subsection 2.2.4 Saving your work

Using Codespaces will keep all your files “in the cloud”, saved automatically as you edit. As long as your Codespace is active, your files will be saved there for your private use. However, inactive Codespaces are periodically cleaned up by GitHub (as of writing, this happens after one month of inactivity), so you’ll need to periodally commit & sync your work to your repository where it will never be deleted.
Recall that your Codespace lives at github.dev, while your repository has a github.com address like https://github.com/username/reponame). This repository serves as a backup of your work in the Codespace, and has the added benefit of allowing collaborators to access your files as well. As a bonus, if you made your repository public, members of the PreTeXt community who watch the PreTeXt-support 1  Google group can create their own Codespace based on your public repository and easily answer any questions you have.
While Git and GitHub have a lot of features, there’s a very simple way to use them via Codespaces. As you edit files, you’ll notice that their filenames will turn orange, and new files will appear green. Likewise, a blue number will appear in the left sidebar.
Screenshot of VS Code sidebar in Codespaces
Figure 2.2.4.2. Filenames changing color as they are edited in Codespaces
This blue badge is next to the Source Control view. You will notice a list of files that were changed; you can click on any of these to see what the changes are.
Screenshot of VS Code Git diff in Codespaces
Figure 2.2.4.3. A “Git diff” showing changes in a file
Type a message describing the changes you’ve made then click the green “Commit and Sync” button. If it just says “Commit”, use the drop-down menu to choose “Commit and Sync”. (If you forget to type a message describing the changes you’ve made, then a new tab will open: “COMMIT_EDITMSG” where you can type the message. When you are done, close the tab.)
Screenshot of VS Code source control in Codespaces
Figure 2.2.4.4. Commiting and syncing changes
To see that this is successful, return to your github.com repository webpage. You should see your files with all your committed/synced changes. (That is, most of them: many files, such as log files and temporary build files that appear in gray within your Codespace, will not be synced. This is no problem: they are created during a build automatically and don’t need to be, and really shouldn’t be, saved or shared with others.)
groups.google.com/g/pretext-support