[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Use Git source code management\n\nSecure Source Manager supports all\n[Git SCM](https://git-scm.com/)\nclient commands and has built in pull requests and issue tracking. Both HTTPS\nand\n[SSH authentication](/secure-source-manager/docs/ssh-keys)\nare supported.\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to use Git to interact with a Secure Source Manager repository,\n\nask your administrator to grant you the\nfollowing IAM roles:\n\n- [Secure Source Manager Instance Accessor](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.instanceAccessor) (`roles/securesourcemanager.instanceAccessor`) on the Secure Source Manager instance\n- To clone a repository: [Secure Source Manager Repo Reader](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoReader) (`roles/securesourcemanager.repoReader`) on the repository\n- To push to a repository: [Secure Source Manager Repo Writer](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoWriter) (`roles/securesourcemanager.repoWriter`) on the repository\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nFor information on granting Secure Source Manager roles,\nsee [Access control with IAM](/secure-source-manager/docs/access-control) and\n[Grant users instance access](/secure-source-manager/docs/grant-users-instance-access).\n\nInstall Git and Google Cloud CLI\n--------------------------------\n\n1. Install\n [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).\n\n2. If you are prompted to **Choose a credential helper** by the Git installer,\n select **None (Do not use a credential helper)**.\n\n3. [Install the gcloud CLI](/sdk/docs/install).\n\n4. The gcloud CLI version `395.0.0` or later is required to use Git\n with HTTPS. To check your gcloud CLI version run the\n following command:\n\n gcloud --version\n\n5. To update the gcloud CLI run the following command.\n\n gcloud components update\n\n6. After updating, run `gcloud init` to\n [initialize the gcloud CLI](/sdk/docs/initializing).\n\n See the gcloud CLI documentation on\n [updating components](/sdk/docs/components#updating_components)\n for more information.\n\nSet up your credentials\n-----------------------\n\nIf you authenticate to Secure Source Manager using a third-party identity\nprovider and Workforce Identity Federation, you don't need to complete this\nsection---instead, you must\n[create a workforce identity pool login configuration](#workforce-identity-pool-login-configuration).\n\nAdd the Secure Source Manager authentication helper to your global Git config\nby running the following command: \n\n### Linux\n\n git config --global credential.'https://*.*.sourcemanager.dev'.helper gcloud.sh\n\nEarlier versions of Git might not support wildcards. To add the\nauthentication helper without wildcards, run the following command: \n\n git config --global credential.'https://\u003cvar translate=\"no\"\u003eINSTANCE_ID\u003c/var\u003e-\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e-git.\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e.sourcemanager.dev'.helper gcloud.sh\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eINSTANCE_ID\u003c/code\u003e\u003c/var\u003e with the name of your Secure Source Manager instance.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ePROJECT_NUMBER\u003c/code\u003e\u003c/var\u003e with your project number. For help finding your project number, see [Identifying projects](/resource-manager/docs/creating-managing-projects#identifying_projects).\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eLOCATION\u003c/code\u003e\u003c/var\u003e with the instance's region. For more information on regions, see [Locations](/secure-source-manager/docs/locations).\n\n### Windows\n\n git config --global credential.https://*.*.sourcemanager.dev.helper gcloud.cmd\n\nEarlier versions of Git might not support wildcards. To add the\nauthentication helper without wildcards, run the following command: \n\n git config --global credential.https://\u003cvar translate=\"no\"\u003eINSTANCE_ID\u003c/var\u003e-\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e-git.\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e.sourcemanager.dev.helper gcloud.cmd\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eINSTANCE_ID\u003c/code\u003e\u003c/var\u003e with the name of your Secure Source Manager instance.\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003ePROJECT_NUMBER\u003c/code\u003e\u003c/var\u003e with your project number. For help finding your project number, see [Identifying projects](/resource-manager/docs/creating-managing-projects#identifying_projects).\n- \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eLOCATION\u003c/code\u003e\u003c/var\u003e with the instance's region. For more information on regions, see [Locations](/secure-source-manager/docs/locations).\n\nThe authentication helper uses the gcloud CLI to fetch your\nGoogle Cloud credentials when using Git commands with\nSecure Source Manager.\n\nTo re-authenticate after the initial credential setup, run the following\ngcloud CLI command: \n\n gcloud auth login\n\n| **Note:** some systems might try to store credentials fetched by authentication helpers by adding a line to your Git config similar to `*credential*.helper=store`. Since the Secure Source Manager credentials are short lived, this will cause authentication errors. To fix this issue, remove the line from your global, system, or local repository Git config file.\n\nCreate a workforce identity pool login configuration\n----------------------------------------------------\n\nYou don't need to complete this section unless you're using\nWorkforce Identity Federation to authenticate to Secure Source Manager with a\nthird-party identity provider.\n\nTo authenticate with your workforce identity pool credentials to your\nSecure Source Manager instance using gcloud CLI commands or Git\ncommands, you must create a login configuration with your workforce identity\npool.\n\nTo create a workforce identity pool login configuration, follow the instructions\nin [Obtain short-lived tokens for Workforce Identity Federation](/sdk/docs/authorizing#auth-wfif) to\ncreate a browser-based sign-in with the gcloud CLI.\n\nAfter you have authenticated, you can use Git commands to interact with\nyour Secure Source Manager instance. You must re-authenticate when the\n**session duration** for your workforce identity pool expires.\n\nClone a repository\n------------------\n\nClone a repository by running the following command: \n\n git clone \u003cvar translate=\"no\"\u003eREPOSITORY_URL\u003c/var\u003e\n\nWhere \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eREPOSITORY_URL\u003c/code\u003e\u003c/var\u003e is the HTTPS or SSH URL displayed at the top\nof the repository page you want to clone.\n\nPush an existing repository to Secure Source Manager\n----------------------------------------------------\n\nYou must [create a Secure Source Manager repository](/secure-source-manager/docs/create-repository) to act as a\nremote before you can push to it.\n\nTo push your existing Git repository to an empty Secure Source Manager\nrepository you need to add the Secure Source Manager repository as a remote\nand push to it.\n\n1. To set the Secure Source Manager repository as a remote run the following\n command:\n\n git remote add origin \u003cvar translate=\"no\"\u003eREPOSITORY_URL\u003c/var\u003e\n\n Where \u003cvar translate=\"no\"\u003e\u003ccode translate=\"no\" dir=\"ltr\"\u003eREPOSITORY_URL\u003c/code\u003e\u003c/var\u003e is the HTTPS or SSH URL displayed at the top of the\n repository page.\n2. To push to the repository run the following command:\n\n git push -u origin main\n\nFor more information on Git source code management, read the\n[Git documentation](https://git-scm.com/doc).\n\nWhat's next\n-----------\n\n- Learn more about [Git source code management](https://git-scm.com/)\n- [List and view repositories](/secure-source-manager/docs/list-view-repositories)."]]