You can save the contents of a notebook instance to GitHub to back up your notebook, as well as make it available to others to use.
To save a notebook to GitHub, follow these steps:
Create a GitHub repository.
If you do not already have a GitHub repository, you must create one. When you create your GitHub repository, initialize the repository with a README file to ensure that a master branch is created.
Configure your notebook instance with your GitHub user information.
Go to the AI Platform Notebooks page in the Google Cloud Console.
Open your notebook instance by clicking Open JupyterLab.
Select Git -> Open Terminal to open a Git terminal window.
In the Git terminal window, enter the following commands to configure your Git user name and email:
git config --global user.name "your-name" git config --global user.email "your-email"
If your GitHub account requires SSH authentication, there are a few more steps to connect your account. From your Git terminal window in AI Platform Notebooks, follow GitHub's instructions for generating a new SSH key. Then follow the instructions for adding that SSH key to your GitHub account.
Close the Git terminal window.
Clone your GitHub repository in your notebook instance.
Copy the URL for your GitHub repository. You can get this from the Clone or download option in your GitHub repository.
In your notebook instance, select the folder where you want to clone the GitHub repository. For example, the home folder as shown below:
Click the Git clone button.
When prompted, paste in the URL for your GitHub repository that you copied earlier. Then click Clone.
Your notebook instance shows your repository as a new folder. If you do not see your cloned GitHub repository as a folder, click the Refresh File List button.
Double-click your repository folder to open it.
Add a new notebook to your notebook instance.
Select File -> New -> Notebook. This creates a new notebook named "Untitled.ipynb". Select the kernel for your new notebook. For example, "Python 3". You can also create a Python 3 notebook using the Launcher.
Select the Git tab. Your new notebook is listed in the Untracked grouping.
Right-click the new notebook and select Track to add the new notebook as a file for your GitHub repository. Your notebook is now added to the Staged grouping in the Git tab.
To commit your new notebook to your GitHub repository, add a commit comment in the Git tab and click the Commit button.
Select Git -> Open terminal to open a Git terminal window.
git pushcommand in the Git terminal window. When prompted, enter your GitHub username and password.
git pushcommand completes, your committed files have been added to your GitHub repository.