Check in Code and Restart Codespaces¶
After you have written a few programs, you have changes to source code in your Codespace. If you want to save those changes for later – and you almost certainly do – you should “check it in” to git. If you don’t, eventually your Github codespace will be stopped automatically, then deleted after a few weeks, and you will lose your changes. So check your code in!
On the left side of the Codespace window, look for this icon. The number may be different.
This is the Source Control icon; click on it to get accecss to the Source Control tool for checking in your code. Now the Source Control pane should look like this:
To check in your code enter a message in the Message box to describe what you changed, then click on the ✓ Commit button. That will check in your changes, but they aren’t really stored permanaently yet.
After you commit, the blue button will change to:
Click the Sync button, and now your changes are safely in your Github account’s repository.
One problem you might have is if you click the ✓ Commit button and it doesn’t seem to do anything, but the edit pane ( where you edit files ) changes to look like this:
This happens if you click the ✓ Commit button without entering a commit message first. There are two ways to proceed:
Close the edit message file by clicking on the x in the files tab. then go back to the Source Control window and enter a message before clicking on the ✓ Commit button.
Enter a commit message at the top of the edit message file, save the file, then close it, and the commit process will finish.
Remember to check in your code frequently! The best thing to do is check in after every lesson, but you should be especially diligent about checking code in before you finish your lessons for the day.
Continue Your Lessons¶
When you want to resume your lessons, you will probably find that your Codespace has been automatically stopped. You should have check in your code, but if you didn’t, your changes will still be in the code space. If you left the browser window open, it will look like this:
If you see that, just click on the green “Restart Codespace” to pick up where you left off.
If you don’t still have that window open, it is still easy to restart your code space.
First, go your Github account and look for the repository called “Python-Apprentice.”
Next, click on the button, and in the popup window, select the “Codespaces” tab. You shout not see the green “Create Codespace” button, but rather, it should look something like this:
The codespaces have crazy names, like this one, “expert brocolli”.
If your codespace isn’t actually stopped, it is still running, you will see “Active” along with a green dot:
Either way, you can click on the crazy name link to open the codespace and continue your lessons.