Seit dem 17. Juni 2024 ist Cloud Source Repositories für Neukunden nicht mehr verfügbar. Wenn Ihre Organisation noch nicht Cloud Source Repositories verwendet hat, können Sie die API nicht aktivieren oder Cloud Source Repositories verwenden. Für neue Projekte, die nicht mit einer Organisation verbunden sind, kann die Cloud Source Repositories API nicht aktiviert werden. Organisationen, die Cloud Source Repositories vor dem 17. Juni 2024 verwendet haben, sind von dieser Änderung nicht betroffen.
Code per Push aus einem vorhandenen Repository übertragen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Thema wird gezeigt, wie Sie Code aus einem vorhandenen Repository auf Ihrem lokalen Computer per Push nach Cloud Source Repositories übertragen.
Vorbereitung
Sie müssen über ein Repository in Cloud Source Repositories verfügen. Informationen zum Erstellen eines Repositorys finden Sie unter Leeres Repository erstellen.
Lokales Repository per Push an Cloud Source Repositories übertragen
Sie können ein lokales Repository per Push mithilfe von SSH, der Google Cloud CLI oder manuell generierten Anmeldedaten an Cloud Source Repositories übertragen.
[PROJECT_NAME] ist der Name Ihres Google Cloud Projekts.
[REPO_NAME] ist der Name Ihres Repositorys.
Übertragen Sie den Code per Push an Cloud Source Repositories:
git push --all google
Das Repository als Remote-Repository verwenden
Google Cloud -Repositories sind Git-Repositories mit komplettem Funktionsumfang. Sie können den Standardsatz von Git-Befehlen verwenden, um mit diesen Repositories zu interagieren, darunter push, pull, clone und log.
Per Push in ein Google Cloud -Repository übertragen
Geben Sie den folgenden Befehl ein, um eine Push-Übertragung von Ihrem lokalen Git-Repository in ein Google Cloud -Repository vorzunehmen:
git push google master
Aus einem Google Cloud -Repository abrufen
Geben Sie den folgenden Befehl ein, um eine Pull-Übertragung von einem Google Cloud -Repository in ein lokales Git-Repository vorzunehmen:
git pull google master
Commit-Verlauf eines Google Cloud -Repositorys aufrufen
Geben Sie den folgenden Befehl ein, um sich den Commit-Verlauf anzeigen zu lassen:
git log google/master
Weitere Informationen
Nachdem Sie Ihr lokales Repository auf Ihren lokalen Computer übertragen haben, können Sie:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-11 (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)."]]