A partir de 17 de junho de 2024, o Cloud Source Repositories não vai mais estar disponível para novos clientes. Se a sua organização ainda não tiver usado o Cloud Source Repositories, não será possível ativar a API nem usar o Cloud Source Repositories. Novos projetos não conectados a uma organização não poderão ativar a API Cloud Source Repositories. As organizações que usaram o Cloud Source Repositories antes de 17 de junho de 2024 não serão afetadas por essa mudança.
Envie seu código para o Cloud Source Repositories:
git push --all google
Usar repositório como controle remoto
Os repositóriosGoogle Cloud são repositórios Git com todos os recursos. Use
o conjunto padrão de comandos do Git para interagir com esses repositórios, incluindo
push, pull, clone e log.
Enviar para um repositório Google Cloud
Para enviar do repositório Git local para um repositório Google Cloud , digite
o seguinte comando:
git push google master
Extrair de um repositório Google Cloud
Para extrair de um repositório Google Cloud para seu repositório Git local, digite
o seguinte comando:
git pull google master
Conferir o histórico de confirmações de um repositório Google Cloud
Para visualizar o histórico de confirmação, digite o seguinte comando:
git log google/master
A seguir
Depois de enviar seu repositório local para a máquina local, será possível:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 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)."]]