Mulai 17 Juni 2024, Cloud Source Repositories tidak tersedia untuk pelanggan baru. Jika organisasi Anda belum pernah menggunakan Cloud Source Repositories, Anda tidak dapat mengaktifkan API atau menggunakan Cloud Source Repositories. Project baru yang tidak terhubung ke organisasi tidak dapat mengaktifkan Cloud Source Repositories API. Organisasi yang telah menggunakan Repositori Sumber Cloud sebelum 17 Juni 2024 tidak akan terpengaruh oleh perubahan ini.
Skrip credential helper memberikan informasi yang diperlukan Git untuk terhubung secara aman ke Cloud Source Repositories menggunakan kredensial Akun Google Anda. Anda tidak perlu melakukan langkah-langkah konfigurasi tambahan
(misalnya, mengupload kunci ssh) untuk membuat koneksi yang aman ini.
Buat repositori di Cloud Source Repositories:
gcloudsourcereposcreate[REPO_NAME]
Dengan [REPO_NAME] adalah nama untuk Google Cloud repositori Anda.
Menambahkan repositori sebagai repositori jarak jauh:
[REPO_NAME] adalah nama repositori Google Cloud Anda.
Menggunakan repositori sebagai remote
Google Cloud adalah repositori Git berfitur lengkap. Anda dapat menggunakan serangkaian perintah Git standar untuk berinteraksi dengan repositori ini, termasuk push, pull, clone, dan log.
Mengirim ke repositori Google Cloud
Untuk mengirim dari repositori Git lokal ke repositori Google Cloud , masukkan perintah ini:
git push google master
Menarik dari repositori Google Cloud
Untuk menarik dari repositori Google Cloud ke repositori Git lokal Anda, masukkan perintah ini:
git pull google master
Melihat histori commit repositori Google Cloud
Untuk melihat histori commit, masukkan perintah ini:
git log google/master
Membuat kredensial statis
Dalam beberapa kasus, Anda mungkin tidak memiliki akses ke gcloud CLI. Misalnya,
Anda mungkin bekerja di server build yang tidak memiliki akses ke alat ini. Dalam
situasi ini, Anda dapat membuat kredensial statis secara manual.
Di konsol Google Cloud , buka Cloud Source Repositories.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]