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.
Die Credential Helper-Skripts stellen die Informationen zur Verfügung, die von Git benötigt werden, um mithilfe Ihrer Google-Kontoanmeldedaten eine sichere Verbindung zum Cloud Source Repository herzustellen. Sie müssen keine zusätzlichen Konfigurationsschritte (z. B. das Hochladen von ssh-Schlüsseln) ausführen, um diese sichere Verbindung herzustellen.
Erstellen Sie das Repository in Cloud Source Repositories:
gcloudsourcereposcreate[REPO_NAME]
Dabei ist [REPO_NAME] der Name für Ihr Google Cloud -Repository.
Fügen Sie ein Repository als Remote-Repository hinzu:
[PROJECT_ID] ist die Projekt-ID Ihres Google Cloud .
[REPO_NAME] ist der Name Ihres Google Cloud Repositorys.
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 an ein Google Cloud -Repository übertragen
Geben Sie 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 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 ansehen
Geben Sie folgenden Befehl ein, um sich den Commit-Verlauf anzeigen zu lassen:
git log google/master
Statische Anmeldedaten generieren
In einigen Fällen haben Sie möglicherweise keinen Zugriff auf die gcloud CLI. Beispielsweise könnten Sie auf einem Build-Server arbeiten, der keinen Zugriff auf diese Tools bietet. In diesen Situationen können Sie statische Anmeldedaten manuell generieren.
Öffnen Sie Cloud Source Repositories in der Google Cloud Console.
Halten Sie den Mauszeiger über das Repository, das Sie klonen möchten.
Klicken Sie auf Klonenadd_box.
Ein Dialogfeld mit Authentifizierungsoptionen wird geöffnet.
Klicken Sie auf den Tab Manuell generierte Anmeldedaten und folgen Sie der Anleitung, um Ihr Repository zu klonen.
Nächste Schritte
Nachdem Sie die Quelldateien per Push an Cloud Source Repositories übertragen haben, können Sie sich die Repository-Dateien in der Google Cloud Console anzeigen lassen.
[[["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,["# 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)."]]