Effective June 17, 2024, Cloud Source Repositories isn't available to new customers. If your organization hasn't previously used Cloud Source Repositories, you can't enable the API or use Cloud Source Repositories. New projects not connected to an organization can't enable the Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to June 17, 2024 are not affected by this change.
Credential helper scripts provide the information that Git needs to connect
securely to Cloud Source Repositories using your Google Account
credentials. You don't need to perform any additional configuration steps
(for example, uploading ssh keys) to establish this secure connection.
Create the repository in Cloud Source Repositories:
gcloudsourcereposcreate[REPO_NAME]
Where [REPO_NAME] is the name for your Google Cloud repository.
[REPO_NAME] is the name of your Google Cloud repository.
Use the repository as a remote
Google Cloud repositories are fully featured Git repositories. You can use
the standard set of Git commands to interact with these repositories, including
push, pull, clone, and log.
Push to a Google Cloud repository
To push from your local Git repository to a Google Cloud repository, enter
this command:
git push google master
Pull from a Google Cloud repository
To pull from a Google Cloud repository to your local Git repository, enter
this command:
git pull google master
View the commit history of a Google Cloud repository
To view the commit history, enter this command:
git log google/master
Generate static credentials
In some cases, you might not have access to the gcloud CLI. For example,
you might work on a build server that doesn't have access to these tools. In
these situations, you can manually generate static credentials.
In the Google Cloud console, open Cloud Source Repositories.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Adding a repository as a remote\n\nYou can use Cloud Source Repositories to add a Google Cloud\nrepository as a remote to a local Git repository.\n| **Note:** You can add only private repositories as remotes.\n\nBefore you begin\n----------------\n\n1. 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)\n2. Install [Git](http://git-scm.com/).\n3.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n 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\nAdd the repository as a remote\n------------------------------\n\n1. Change your current working directory to the directory that contains your\n local Git repository:\n\n cd [REPO_DIRECTORY]\n\n Where `[REPO_DIRECTORY]` is the path to your repository.\n2. On Linux or macOS, run the credential helper script:\n\n ### Linux or macOS\n\n git config --global credential.'https://source.developers.google.com'.helper gcloud.sh\n\n ### Windows\n\n git config --global credential.https://source.developers.google.com.helper gcloud.cmd\n\n Credential helper scripts provide the information that Git needs to connect\n securely to Cloud Source Repositories using your Google Account\n credentials. You don't need to perform any additional configuration steps\n (for example, uploading `ssh` keys) to establish this secure connection.\n | **Note:** The Google Cloud CLI must be in your `$PATH` for the credential helper scripts to work. If you cannot use the Google Cloud CLI, you can manually generate static credentials. For example, if you're on a build server, you might not have access to the gcloud CLI. For more information, see [Generating static credentials](#generate_static_credentials) in this topic.\n3. Create the repository in Cloud Source Repositories:\n\n gcloud source repos create [REPO_NAME]\n\n Where `[REPO_NAME]` is the name for your Google Cloud repository.\n4. Add a repository as a remote:\n\n git remote add google \\\n https://source.developers.google.com/p/[PROJECT_ID]/r/[REPO_NAME]\n\n Where:\n - `[PROJECT_ID]` is your Google Cloud project ID.\n - `[REPO_NAME]` is the name of your Google Cloud repository.\n\nUse the repository as a remote\n------------------------------\n\nGoogle Cloud repositories are fully featured Git repositories. You can use\nthe standard set of Git commands to interact with these repositories, including\n`push`, `pull`, `clone`, and `log`.\n\n### Push to a Google Cloud repository\n\nTo push from your local Git repository to a Google Cloud repository, enter\nthis command: \n\n git push google master\n\n### Pull from a Google Cloud repository\n\nTo pull from a Google Cloud repository to your local Git repository, enter\nthis command: \n\n git pull google master\n\n### View the commit history of a Google Cloud repository\n\nTo view the commit history, enter this command: \n\n git log google/master\n\nGenerate static credentials\n---------------------------\n\nIn some cases, you might not have access to the gcloud CLI. For example,\nyou might work on a build server that doesn't have access to these tools. In\nthese situations, you can manually generate static credentials.\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 the 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\nWhat's next\n-----------\n\n- After you have pushed source files to Cloud Source Repositories, you can\n view repository files from within the Google Cloud console.\n\n- [Learn how to use the source browser](/source-repositories/docs/using-source-browser)."]]