Attach Git repos
JupyterLab offers a Git extension to enter the URL of a Git repository (repo), clone it into an environment, push changes, and view the commit history. You can also attach suggested Git repo URLs to a Amazon SageMaker domain (domain) or user profile.
The following sections show how to attach Git repo URLs to a domain or user profile from the Amazon Command Line Interface (Amazon CLI) and the SageMaker console. A section also provides Amazon CLI commands to detach these repository URLs.
Attach a Git repository (Amazon CLI)
This section shows how to attach a Git repository (repo) URL using the Amazon CLI. After you attach the Git repo URL, you can clone it by following the steps in Clone a Git repo in Amazon SageMaker Studio.
Prerequisites
Before you begin, complete the following prerequisites:
-
Update the Amazon CLI by following the steps in Installing the current Amazon Command Line Interface Version.
-
From your local machine, run
aws configure
and provide your Amazon credentials. For information about Amazon credentials, see Understanding and getting your Amazon credentials. -
Onboard to Amazon SageMaker domain. For more information, see Amazon SageMaker domain overview.
Attach the Git repo to a Amazon SageMaker domain (domain) or user profile
Git repo URLs that are associated at the domain level are inherited by all users. However, Git repo URLs that are associated at the user profile level are scoped to a specific user. You can attach multiple Git repo URLs to a Amazon SageMaker domain or to a user profile by passing a list of repository URLs.
The following sections show how to attach a Git repo URL to your domain and your user profile.
Attach to a Amazon SageMaker domain
The following command attaches a Git repo URL to an existing domain:
aws sagemaker update-domain --region
region
--domain-iddomain-id
\ --default-user-settings JupyterLabAppSettings={CodeRepositories=[{RepositoryUrl="repository
"}]}
Attach to a user profile
The following command attaches a Git repo URL to an existing user profile:
aws sagemaker update-user-profile --domain-id
domain-id
--user-profile-nameuser-name
\ --user-settings JupyterLabAppSettings={CodeRepositories=[{RepositoryUrl="repository
"}]}
Clone a Git repo in Amazon SageMaker Studio
Amazon SageMaker Studio connects to a local Git repo only. To access the files in the repo, clone the Git repo from within Studio. To do so, Studio offers a Git extension for you to enter the URL of a Git repo, clone it into your environment, push changes, and view commit history.
If the repo is private and requires credentials to access, you receive a prompt to
enter your user credentials. Your credentials include your username and personal access
token. For more information about personal access tokens, see Managing your personal access tokens
Admins can also attach suggested Git repository URLs at the Amazon SageMaker domain or user profile level. Users can then select the repo URL from the list of suggestions and clone that into Studio. For more information about attaching suggested repos, see Attach Suggested Git Repos to Studio Classic.
Detach Git repo URLs
This section shows how to detach Git repository URLs from an Amazon SageMaker domain (domain) or a user profile. You can detach repo URLs by using the Amazon Command Line Interface (Amazon CLI) or the Amazon SageMaker console.
Detach a Git repo using the Amazon CLI
To detach all Git repo URLs from a domain or user profile, you must pass an empty list
of code repositories. This list is passed as part of the
JupyterLabAppSettings
parameter in an update-domain
or
update-user-profile
command. To detach only one Git repo URL, pass the
code repositories list without the desired Git repo URL.
Detach from an Amazon SageMaker domain
The following command detaches all Git repo URLs from a domain:
aws sagemaker update-domain --region
region
--domain-namedomain-name
\ --domain-settings JupyterLabAppSettings={CodeRepositories=[]}
Detach from a user profile
The following command detaches all Git repo URLs from a user profile:
aws sagemaker update-user-profile --domain-name
domain-name
--user-profile-nameuser-name
\ --user-settings JupyterLabAppSettings={CodeRepositories=[]}