Use Git repositories as workspace resources
The procedures below explain how to manage your Git repositories as workspace resources.
Purpose and benefits
Add a Git repository to your workspace resources if you want to use it as a Python library with a setup.py file in it. Once added to the selected workspace, this repository can be installed into any notebook residing in that workspace. It has the following benefits:
You set up, store, and manage Git repositories on workspace level.
You can attach Git repositories to any notebook from the workspace where these repositories reside.
When setting up a Git repository, you use SSH keys stored in the same workspace.
This approach ensures SSH keys security as they are never accessible on the agent.
Add a Git repository to a workspace
The procedure explains how to add a Git repository to a workspace from the Home page.
On the Home page, select the workspace to which you want to add the repository.
From the left-hand side menu, select Other and switch to the Repositories tab. This will open the list of Git repositories in the selected workspace.
On the Repositories tab, click the Add button in the upper right corner.
In the Add repository connection dialog, do the following:
In the Display name field, provide a name under which the repository will be listed in the workspace.
Provide the URL of the repository in the respective field.
(Optional) To provide an SSH key, expand the list under SSH key and select one of the keys available in this workspace. For more details, see Manage SSH keys.
For Default reference, select the repository branch you want to reference. To use a branch other than the default one, click Fetch the list of available repository references, expand the Default reference list, and select a branch.
Click the Test connection button.
Once the connection is successfully tested, click the Create and close button.
Now that the new Git repository connection is added, you can attach it to notebooks.
Add a Git repository through notebook environment
The procedure adds a Git repository to the environment of the selected notebook as a Python library and also adds it to the resources of the respective workspace, which makes it available for any other notebook residing there.
Open the notebook and click the Environment icon on the left-hand sidebar of the editor.
Switch to the Repositories tab.
Click the Add connection button.
In the Add repository connection dialog, do the following:
In the Display name field, provide a name under which the repository will be listed in the workspace.
Provide the URL of the repository in the respective field.
(Optional) To provide an SSH key, expand the list under SSH key and select one of the keys available in this workspace. For more details, see Manage SSH keys.
For Default reference, select the repository branch you want to reference. To use a branch other than the default one, click Fetch the list of available repository references, expand the Default reference list, and select a branch.
Click the Test connection button.
Once the connection is successfully tested, click the Create and close button.
Manage workspace Git repositories
On the Home page, select the workspace to which you want to add the repository.
From the left-hand side menu, select Data and switch to the Repositories tab. This will open the list of Git repositories in the selected workspace.
In the Repositories view, right-click the repository you want to manage.
Use the following options available in the popup menu:
Edit: to change the display name, URL, SSH key, or default reference of the repository.
Rename: to change the display name of the repository.
Clone: to close the repository to the same workspace. It will be added to the same list under a slightly different name.
Clone to other workspaces: to clone the repository to other workspaces. You will be prompted to select where to clone the repository.
Attach a workspace Git repository to a notebook
This is the easiest way to install a publicly available Git repository from the user interface into a single Datalore notebook.
Open the notebook and click the Environment icon on the left-hand sidebar of the editor.
Switch to the Repositories tab.
Click the Select repository to attach to expand the list of workspace repositories.
Select a repository from the expanded list.
In the Select reference popup window, do one of the following:
Click the Apply button to use the default reference set on the workspace level.
Select the other radio button to override the default reference, select a branch, and click the Apply button.
After the repository is attached, click restart kernel in the notification popup to complete the environment update.
If you want to access a private Git repository with a personal token or via credentials, use the init.sh script.
Manage notebook's attached Git repositories
In the notebook, open the Environment tool from the left-hand sidebar.
Switch to Repositories.
In the repository list, right-click the item you want to manage.
Use the following options available in the popup menu:
Update repository: to update the attached repository.
Change reference: to change the repository reference. You can select the default reference set on the workspace level or any other repository branch.
Edit: to change the display name, URL, SSH key, or default reference of the repository.
Show installation log: to view or copy the log of the repository installation.
Detach connection: to detach the repository connection from the notebook. The repository connection will remain available as a workspace resource.