Cloning a repository

Once you have a Cloud Source Repository set up as described in Setting up a Repository, you can create a new local Git repository.

This is accomplished by cloning the contents of an existing Cloud Source Repository:

Note: Run gcloud init after installing gcloud and before you start cloning repositories.

gcloud source repos clone [REPO_NAME] [LOCAL_DIRECTORY]

The gcloud source repos clone command adds the Cloud Source Repository as a remote named origin and clones it into a local Git repository located in [LOCAL_DIRECTORY]. It also configures a credential helper to be used on this repository. This helper authenticates future git commands with your gcloud credentials so that you won't be required to enter your password.

For Windows users: Some of the standard git installations set a system-wide credential helper. If this credential manager creates a dialog box asking for a username and password, click cancel to allow the gcloud CLI to supply credentials.

For MacOS users: When using a tool for your git operations that does not include gcloud in the path, you will need to qualify your clone command with the full gcloud path for the credential helper to work.

For MacOS users, qualifying your clone command with the full gcloud path, as in the note above, means that gcloud does not need to be in the path for future git operations on the repository.

gcloud beta source repos clone --use-full-gcloud-path [REPO_NAME] [LOCAL_DIRECTORY]

Send feedback about...

Cloud Source Repositories