Cloning a repository

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

To create a local repository, use the gcloud source repos clone command to clone the content from Google Cloud Source Repositories to your local machine.

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 content from a GCP repository as a remote named origin and clones it into a local Git repository located in [LOCAL_DIRECTORY]. The command also configures a credential helper. This helper authenticates future Git commands with your Cloud SDK 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.

Using your clone command with the `use-full-gcloud-path` parameter allows the credential helper to work even when the gcloud command-line tool is not in your path.

gcloud beta source repos clone --use-full-gcloud-path [REPO_NAME] [LOCAL_DIRECTORY]
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Source Repositories