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.
Os scripts auxiliares de credencial fornecem as informações necessárias para que o Git se conecte com segurança ao Cloud Source Repositories usando as credenciais da sua Conta do Google. Não é preciso executar nenhuma etapa de configuração adicional (como fazer o upload de chaves ssh) para estabelecer essa conexão segura.
Crie o repositório no Cloud Source Repositories:
gcloudsourcereposcreate[REPO_NAME]
Em que [REPO_NAME] é o nome do seu Google Cloud repositório.
[REPO_NAME] é o nome do seu repositório Google Cloud .
Usar repositório como controle remoto
OsGoogle 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 este 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 este comando:
git pull google master
Conferir o histórico de commits de um repositório Google Cloud
Para ver o histórico de confirmação, digite este comando:
git log google/master
Gerar credenciais estáticas
Em alguns casos, talvez você não tenha acesso à CLI gcloud. Por exemplo, é possível trabalhar em um servidor de versão que não tenha acesso a essas ferramentas. Nessas situações, é possível gerar credenciais estáticas manualmente.
No console Google Cloud , abra o Cloud Source Repositories.
[[["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-03 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)."]]