Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-11 (世界標準時間)。"],[],[],null,["# Creating an empty repository\n\nYou can use Cloud Source Repositories to create a new, empty repository. Creating a\nrepository is useful when you want to start a project or back up a Git\nrepository using Cloud Source Repositories.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n2. If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n3.\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n4. [Verify that you have the latest version of Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).\n5. If you have not configured your user credentials in Git, follow the [first time setup instructions.](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup)\n6. Enable the Cloud Source Repositories API.\n7. [Enable the Cloud Source Repositories API](https://console.cloud.google.com/flows/enableapi?apiid=sourcerepo.googleapis.com&redirect=https://cloud.google.com/source-repositories/docs/creating-an-empty-repository)\n\nCreate a new repository\n-----------------------\n\nYou can create a repository by using either the Google Cloud console or the `gcloud`\ncommand-line tool. \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. Click **Add repository**.\n\n The **Add a repository** page opens.\n3. Select **Create new repository** and click **Continue**.\n\n The **Create new repository** page opens.\n4. In the **Repository name** field, type a name for the new repository.\n Note that the names `All-Users` and `All-Projects` are restricted names\n and cannot be used.\n\n5. In the **Project** drop-down list, select the Google Cloud\n project the repository belongs to.\n\n To [create a new Google Cloud project](#create_a_project), click\n **Create project**.\n6. Click **Create**.\n\n Your repository is created, and the **Add code to your repository** page\n opens. This page provides instructions on how to\n [clone the repository to your local machine](/source-repositories/docs/cloning-repositories)\n or\n [push code from an existing repository](/source-repositories/docs/pushing-code-from-a-repository)\n based on your authentication type.\n\n### gcloud\n\n1. From the command line, call:\n\n gcloud init\n gcloud source repos create [REPO_NAME]\n\n Where `[REPO_NAME]` is the name for your repository. Note that the names\n `All-Users` and `All-Projects` are restricted names and cannot be used.\n\nCreate a project\n----------------\n\nAll repositories must belong to a Google Cloud project. If you don't have\na Google Cloud project, you can create one by following these steps.\n\n1. On the **Create new repository** [page](#create_a_new_repository), click\n **Create project**.\n\n The **Create Cloud project** dialog opens.\n2. In the **Project name** field, type a name for the Google Cloud\n project.\n\n3. In the **Project ID** field, either accept the generated project ID or click\n **Edit Project ID** to enter a different one.\n\n | **Note:** Your Google Cloud project ID must be unique across Google Cloud.\n4. In the **Billing Account** drop-down list, select a billing account.\n\n To create a billing account, click **Create billing account**.\n5. Click **Create**.\n\nYou can continue [creating a new repository](#create_a_new_repository).\n\nWhat's next\n-----------\n\nNow that you have a repository in Cloud Source Repositories, you can now add\nyour code, which might involve either of these processes:\n\n- [Cloning your new repository](/source-repositories/docs/cloning-repositories) to your local machine.\n- [Pushing code from an existing repository](/source-repositories/docs/pushing-code-from-a-repository) on your local machine."]]