Save a notebook to GitHub
To back up your user-managed notebooks instance and make it available to others, save the contents of your user-managed notebooks instance to GitHub.
Create a GitHub repository
If you don't already have a GitHub repository, you must create one.
When you create your GitHub repository make sure that your GitHub repository can be cloned by selecting the Initialize this repository with a README checkbox.
 
 
Clone your GitHub repository in your user-managed notebooks instance
To clone your GitHub repository in your user-managed notebooks instance, complete the following steps:
- In your GitHub repository, click the Code button, and then click the Local tab. 
- Copy the HTTPS URL. 
- In the Google Cloud console, go to the User-managed notebooks page. 
- Click Open JupyterLab to open your user-managed notebooks instance. 
- In the JupyterLab File Browser, select the folder where you want to clone the GitHub repository. For example, the home folder.   
- In JupyterLab, select Git > Clone a Repository. 
- If prompted, enter your credentials. - If you use a GitHub username and password, enter your GitHub username and password. 
- If you use two-factor authentication with GitHub, create and use a personal access token. 
 
- In the Clone a repo dialog, paste the HTTPS URL for your GitHub repository.   
- Click Clone. 
Configure your user-managed notebooks instance with your GitHub user information
- In JupyterLab, select Git > Open Git Repository in Terminal to open a Git terminal window. 
- In the Git terminal window, enter the following commands to configure your Git username and email: - git config --global user.name "YOUR_NAME" git config --global user.email "YOUR_EMAIL" 
- If your GitHub account requires SSH authentication, complete the following steps to connect your account: - From your Git terminal in your user-managed notebooks instance, follow GitHub's instructions for generating a new SSH key. 
- Follow the instructions for adding that SSH key to your GitHub account. 
 
- Close the Git terminal window. 
Add your committed files to your GitHub repository
- Your user-managed notebooks instance shows your repository as a new folder. If you don't 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 user-managed notebooks instance. - To add a notebook file, you can use the menu or the Launcher. - Menu- To add a new notebook file from the menu, select File > New > Notebook.   
- In the Select kernel dialog, select the kernel for your new notebook, for example, Python 3, and then click Select. - Your new notebook file opens. 
 - Launcher- To add a new notebook file from the Launcher, select File > New > Launcher. 
- Click the tile for the kernel you want to use.   - Your new notebook file opens. 
 
- Rename your new notebook file. - Menu- Select File > Rename notebook. The Rename file dialog opens. 
- In the New name field, change - Untitled.ipynbto something meaningful, such as- install.ipynb.
- Click Rename. 
 - Launcher- Right-click the - Untitled.ipynbtab and then click Rename notebook. The Rename file dialog opens.
- In the New name field, change - Untitled.ipynbto something meaningful, such as- install.ipynb.
- Click Rename. 
 
- Select the Git tab. Your new notebook is listed in the Untracked grouping. 
- To add the new notebook as a file for your GitHub repository, right-click the new notebook and select Track. On the Git tab, your notebook is now added to the Staged grouping. 
- To commit your new notebook to your GitHub repository, on the Git tab, add a commit comment and click Commit. 
- To open a Git terminal window, select Git > Open Git repository in terminal. 
- In the Git terminal window, enter the - git pushcommand.- If you use a GitHub username and password, when prompted, enter your GitHub username and password. 
- If you use two-factor authentication with GitHub, create a personal access token to use. 
 - When the - git pushcommand completes, your committed files are in your GitHub repository.