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.
[PROJECT_NAME] is the name of your Google Cloud project.
[REPO_NAME] is the name of your repository.
Push your code to Cloud Source Repositories:
git push --all google
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
the following command:
git push google master
Pull from a Google Cloud repository
To pull from a Google Cloud repository to your local Git repository, enter
the following command:
git pull google master
View the commit history of a Google Cloud repository
To view the commit history, enter the following command:
git log google/master
What's next
After you push your local repository to your local machine, you can:
[[["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,["# Pushing code from an existing repository\n\nThis topic describes how to push code from an existing repository on your local\nmachine to Cloud Source Repositories.\n\nBefore you begin\n----------------\n\nYou must have a repository in Cloud Source Repositories. To create a\nrepository, see\n[Creating an empty repository](/source-repositories/docs/creating-an-empty-repository).\n\nPush a local repository into Cloud Source Repositories\n------------------------------------------------------\n\nYou can push a local repository to Cloud Source Repositories by using either\nSSH, the Google Cloud CLI, or manually generated credentials. \n\n### SSH\n\n1. Ensure you have\n [set up local authentication](/source-repositories/docs/authentication#ssh)\n with SSH.\n\n2. Add your local repository as a remote:\n\n git remote add google 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 remote add google ssh://user@gmail.com@source.developers.google.com:2022/p/example-project/r/test-repo\n\n3. Push your code to Cloud Source Repositories:\n\n git push --all google\n\n### gcloud CLI\n\n1. Ensure that\n [the gcloud CLI is installed](/source-repositories/docs/authentication#authenticate-using-the-cloud-sdk) on your machine.\n\n2. Open a terminal window.\n\n3. If you're using Windows, enter the following command:\n\n gcloud init && git config credential.helper gcloud.cmd\n\n If you're using Linux or macOS, enter the following command: \n\n gcloud init && git config credential.helper gcloud.sh\n\n4. Add your local repository as a remote:\n\n git remote add google \\\n https://source.developers.google.com/p/[PROJECT_NAME]/r/[REPO_NAME]\n\n Where:\n - `[PROJECT_NAME]` is the name of your Google Cloud project.\n - `[REPO_NAME]` is the name of your repository.\n5. Push your code to Cloud Source Repositories:\n\n git push --all google\n\n### Manual\n\n1. Ensure you have\n [generated and stored your Git credentials](/source-repositories/docs/authentication#manually-generated-credentials).\n\n2. Open a terminal window and add your local repository as a remote:\n\n git remote add google \\\n https://source.developers.google.com/p/[PROJECT_NAME]/r/[REPO_NAME]\n\n Where:\n - `[PROJECT_NAME]` is the name of your Google Cloud project.\n - `[REPO_NAME]` is the name of your repository.\n3. Push your code to Cloud Source Repositories:\n\n git push --all google\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\nthe following 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\nthe following 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 the following command: \n\n git log google/master\n\nWhat's next\n-----------\n\nAfter you push your local repository to your local machine, you can:\n\n- [Learn from your code's history](/source-repositories/docs/history-overview).\n- [Search your code](/source-repositories/docs/searching-code)."]]