[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[],[],null,["# Cloning a repository\n\nThis topic describes how to clone the contents of a repository from\nCloud Source Repositories to your local machine.\n\nBefore you begin\n----------------\n\nThe following is required to clone the contents of a repository:\n\n- You must have\n [authentication on your local system](/source-repositories/docs/authentication).\n\n The steps to clone a repository vary depending on your authentication type\n (SSH, Google Cloud CLI, or manually generated credentials).\n- You must have\n [a repository in Cloud Source Repositories](/source-repositories/docs/creating-an-empty-repository).\n\n- You must have\n [permissions to interact with the repository](/source-repositories/docs/configure-access-control).\n\n- The repository to be cloned cannot have a restricted name such as `All-Users`\n or `All-Projects`.\n\nClone using SSH\n---------------\n\nIf you're not using manually generated credentials or the gcloud CLI,\nyou can clone a repository by using SSH. \n\n### Console\n\n1. In the Google Cloud console, open Cloud Source Repositories.\n\n [Open Cloud Source Repositories](https://source.cloud.google.com/repos)\n2. Hold your pointer over the repository you want to clone.\n\n3. Click **Clone** add_box.\n\n A dialog with authentication options opens.\n4. Click the **SSH authentication** tab and follow the\n instructions to clone your repository.\n\n### gcloud\n\n1. Ensure that you're\n [authenticated with SSH](/source-repositories/docs/authentication#ssh)\n on your local machine.\n\n2. On your local system, use your Google Cloud username\n and the fully qualified SSH path to your repository to clone your\n repository:\n\n git clone ssh://[EMAIL]@source.developers.google.com:2022/p/[PROJECT_ID]/r/[REPO_NAME]\n\n Where:\n - `[EMAIL]` is your Google Cloud username.\n - `[PROJECT_ID]` is the ID of the Google Cloud project where the repository is located.\n - `[REPO_NAME]` is the name of the repository.\n\n For example: \n\n git clone ssh://user@gmail.com@source.developers.google.com:2022/p/example-project/r/test-repo\n\nThe first time you connect to Cloud Source Repositories by using SSH,\nyou're asked to confirm the SSH key fingerprints for the remote host. The\nhostname for the repository service is `source.developers.google.com`. The\nfingerprints are: \n\n none\n SHA256:AGvEpqYNMqsRNIviwyk4J4HM0lEylomDBKOWZsBn434\n MD5:74:84:6c:08:d5:b5:54:68:19:da:2a:8e:4c:5b:d3:0d\n\nClone using the gcloud CLI\n--------------------------\n\nIf you're not using SSH or manually generated credentials, you can clone a\nrepository by using the gcloud CLI. \n\n### Console\n\n1. In the Google Cloud console, open Cloud Source Repositories.\n\n [Open Cloud Source Repositories](https://source.cloud.google.com/repos)\n2. Hold your pointer over the repository you want to clone.\n\n3. Click **Clone** add_box.\n\n A dialog with authentication options opens.\n4. Click the **Google Cloud SDK** tab and follow the instructions to\n clone your repository.\n\n### gcloud\n\n1. Ensure that\n [the gcloud CLI is installed](/source-repositories/docs/authentication#authenticate-using-the-cloud-sdk)\n on your local system.\n\n2. In a terminal window, provide your authentication credentials:\n\n gcloud init\n\n3. Clone your repository:\n\n gcloud source repos clone [REPO_NAME] --project=[PROJECT_NAME]\n\n Where:\n - `[REPO_NAME]` is the name of your repository.\n - `[PROJECT_NAME]` is the name of your Google Cloud project.\n\n For example: \n\n gcloud source repos clone test-repo --project=example-project\n\nClone using manually generated credentials\n------------------------------------------\n\nIf you're not using SSH or the gcloud CLI, you can clone a repository\nby using manually generated credentials. \n\n### Console\n\n1. In the Google Cloud console, open Cloud Source Repositories.\n\n [Open Cloud Source Repositories](https://source.cloud.google.com/repos)\n2. Hold your pointer over the repository you want to clone.\n\n3. Click **Clone** add_box.\n\n A dialog with authentication options opens.\n4. Click the **Manually generated credentials** tab and follow the\n instructions to clone your repository.\n\n### gcloud\n\n1. Ensure that you have\n [generated and stored your Git credentials](/source-repositories/docs/authentication#manually-generated-credentials).\n\n2. In a terminal window, enter the following command:\n\n git clone https://source.developers.google.com/p/[PROJECT_NAME]/r/[REPO_NAME]\n\n Where:\n - `[PROJECT_NAME]` is the name of your project.\n - `[REPO_NAME]` is the name of your repository."]]