Git repositories in notebooks

Examples related to using Git repositories in your notebook environments with the Workbench CLI

Prior reading: Overview of the Command Line Interface

Purpose: This document provides summary examples of commands that may be used alone or in combination when using Git repositories in notebook environments.

Git repositories and workspaces

Verily Workbench supports a referenced resource for Git repositories. You can add relevant repositories to a given workspace. Then, when you create a cloud environment in that workspace, the referenced repositories are automatically cloned to the cloud environment. You can then use the Git extensions on the cloud environment to commit and push your changes as described in Git integrations with cloud environments. On your local machine, you can use wb git clone --all to clone all the Git repository references corresponding to a particular workspace to your preferred directory.


These instructions assume that you have already installed the Workbench CLI, or are working in a cloud environment where it has been installed, and that you have logged in and identified the workspace you want to work with as described in Basic usage.

(Optional) Set up your SSH key

If you want to access private Git repositories, then you will first need to associate your Workbench SSH public key with your GitHub account as described in Git integrations with cloud environments.

Add a Git repository to a workspace

Use this command to create Git repository references.

wb resource add-ref git-repo --id="repo_1" --repo-url=
wb resource add-ref git-repo --id="repo_2"

ℹ️ wb resource add-ref

Note that we show two different command examples; one for a public repository (with the https:// construction) and one for a private repository (with the git@ construction). As noted above, private repositories require an SSH key to be set up.

Create a notebook environment pre-loaded with the repositories

Create a cloud environment

Use this command to create a new cloud environment with the desired name. Make sure to replace my-cloud-env with the name you want to use (must be in double quotes).

wb resource create gcp-notebook --id="my-cloud-env"

ℹ️ wb resource create

Get the cloud environment proxy URL and connect to the JupyterLab server

This command prints out descriptive information about the given cloud environment, including the “Proxy URL”, which is the link to access the environment’s JupyterLab server.

wb resource describe –-name="my-cloud-env"

ℹ️ wb resource describe

For any repo references that you have added prior to creating a cloud environment, the Git repository will be automatically cloned to the JupyterLab server’s file system, under the ~/repos directory.

Referenced repos are automatically cloned to the JupyterLab server's file system.

Clone Git repositories after environment creation

If more Git repo resources are subsequently added to the workspace and you want to clone them into a cloud environment that you have already created (e.g., my-cloud-env), you can run the following command in your notebook.

wb git clone --all

ℹ️ wb git

Last Modified: 16 April 2024