Git repositories in notebooks
Categories:
Prior reading: Command-line interface overview
Purpose: This document provides summary examples of commands that may be used alone or in combination when using Git repositories in notebook apps.
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 app in that workspace, the referenced repositories are automatically cloned to the app. You can then use the Git extensions on the app to commit and push your changes as described in Git integrations with cloud apps. 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.
Prerequisites
These instructions assume that you have already installed the Workbench CLI, or are working in a cloud app 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 apps.
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=https://github.com/MyGithubOrg/my-public-project.git
wb resource add-ref git-repo --id="repo_2" --repo-url=git@github.com:MyGithubOrg/my-private-project.git
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 app pre-loaded with the repositories
Create an app
Use this command to create a new app with the desired name. Make sure to replace my-cloud-app
with the name you want to use (must be in double quotes).
wb resource create gcp-notebook --id="my-cloud-app"
Get the app proxy URL and connect to the JupyterLab server
This command prints out descriptive information about the given app, including the "Proxy URL", which is the link to access the app's JupyterLab server.
wb resource describe –-name="my-cloud-app"
For any repo references that you have added prior to creating an app, the Git
repository will be automatically cloned to the JupyterLab server's file system, under the ~/repos
directory.
Clone Git repositories after app creation
If more Git repo resources are subsequently added to the workspace and you want to clone them into an
app that you have already created (e.g., my-cloud-app
), you can run the following command in your notebook.
wb git clone --all
ℹ️ wb git
Last Modified: 13 November 2024