Save a notebook to GitHub

This page describes how you can save your Vertex AI Workbench instance's notebook files to GitHub by using the jupyterlab-git extension. You might do this to create a backup of the notebook or to make the notebook available to others.

In Vertex AI Workbench instances, you can use the jupyterlab-git extension to help you with version control. To learn more, see jupyterlab-git on 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 READMEcheckbox.

Initialize a GitHub repository with a README file.

Clone your GitHub repository in your Vertex AI Workbench instance

To clone your GitHub repository in your Vertex AI Workbench instance, complete the following steps:

  1. In your GitHub repository, click the Codebutton, and then click the Localtab.

  2. Copy the HTTPSURL.

  3. In the Google Cloud console, go to the Instancespage.

    Go to Instances

  4. Click Open JupyterLabto open your Vertex AI Workbench instance.

  5. In the JupyterLab File Browser, select the folder where you want to clone the GitHub repository. For example, the home folder.

    The JupyterLab file browser in Vertex AI Workbench, highlighting the home folder where a GitHub repository can be cloned.

  6. In JupyterLab, select Git  > Clone a Repository.

  7. In the Clone a repodialog, paste the HTTPS URL for your GitHub repository.

    Dialog showing the field for the repository URL and options for submodules and download repository.

  8. 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 .

  9. Click Clone.

  10. Your Vertex AI Workbench instance shows your repository as a new folder. If you don't see your cloned GitHub repository as a folder, click the Refresh File Listbutton.

    The JupyterLab file browser in Vertex AI Workbench, with the Refresh File List button highlighted.

Configure your instance with your GitHub user information

  1. In JupyterLab, open the folder where your repository is located.

  2. Select Git  > Open Git Repository in Terminalto open a Git terminal window.

  3. In the Git terminal window, enter the following commands to configure your Git username and email:

    git config --global user.name " USERNAME 
    "
    git config --global user.email " EMAIL_ADDRESS 
    "

    Replace the following:

    • USERNAME : your GitHub username
    • EMAIL_ADDRESS : your GitHub account email address
  4. If your GitHub account requires SSH authentication, complete the following steps to connect your account:

    1. From your Git terminal in your Vertex AI Workbench instance, follow GitHub's instructions for generating a new SSH key .

    2. Follow the instructions for adding that SSH key to your GitHub account .

  5. Close the Git terminal window.

Add your committed files to your GitHub repository

  1. In JupyterLab, open the folder where your repository is located.

  2. Add a new notebook .

  3. Select the Gittab. Your new notebook is listed in the Untrackedgrouping.

  4. To add the new notebook as a file for your GitHub repository, right-click the new notebook and select Track. On the Gittab, your notebook is now added to the Stagedgrouping.

  5. To commit your new notebook to your GitHub repository, on the Gittab, in the Summaryfield, add a commit comment, and then click Commit.

  6. Select Git  > Push to Remote.

    • If you use a GitHub username and password, when prompted, enter your GitHub username and password.

    • If you use two-factor authentication with GitHub, enter your GitHub username and personal access token.

    After the git push command completes, your committed files are in your GitHub repository.

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: