[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Use version control with Cloud Shell Editor\n\nThis page describes how to use version control for your application files with\nthe Cloud Shell Editor's Git support.\n\nUse version control\n-------------------\n\nBy clicking the Source Control view from the\nActivity bar ,\nyou can access your Git repositories (or create a new one), view existing\nand staged changes, and merge changes.\n\nFrom here, you can stage and unstage changes, diff between the previous\nstate and the current version of files, and commit changes, all from within the Cloud Shell Editor.\n\nAuthenticate with Git\n---------------------\n\nTo pull or push changes to your Git repository or clone your repository, as you\ndo when [importing a custom sample](/code/docs/shell/create-app-from-custom-sample),\nyou must authenticate with Git. If you're working with\n[Cloud Source Repositories](/source-repositories/docs); however,\nCloud Shell handles authentication for you automatically.\n\nWhen you carry out an action that requires authentication, Git prompts you for\na password. Enter a personal access token (PAT; a more secure alternative to Git\npasswords). For details on setting up your PAT, see the\n[Creating a personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) guide.\n\nTo make your workflow more efficient and avoid having to enter your PAT multiple\ntimes, turn on credential helper to allow Git to cache your PAT for\n15 minutes:\n\n1. Launch the Cloud Shell Editor terminal by clicking **Terminal** \\\u003e **New Terminal**.\n2. Run the following command:\n\n git config --global credential.helper cache\n\nFor more customization options like changing timeout length and specifying a\nlocal path for credential storage, see the\n[Git Tools - Credential Storage](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage)\ndocumentation.\n\nToggle between multiple repositories\n------------------------------------\n\nYou can work across multiple Git repositories with the\nCloud Shell Editor. To toggle between your repositories, in the\nCloud Shell Editor status bar, click your repository name. From the\nmenu, select the repository to switch your scope to.\n\nThis updates your Source Control panel with the context of your chosen\nrepository.\n\n### Display working changes\n\nAs you add, modify, and delete files, these changes are reflected under the\nChanges section in your Source Control panel. You can choose to open\nthe selected file, stage these changes, discard changes, or see what changes\nare being made in this commit.\n\n### Turn on diff view\n\nIn the Source Control panel, your changed files are listed under\nChanges. If you've staged your changed files, they're also listed under Staged\nChanges. Clicking any of these files brings up their diff view, showing you\nwhat's changed between the previously committed state of the file and the\ncurrent state.\n\n### Commit changes\n\nWhen you're ready to check in your changes, you can do so right from within\nthe Cloud Shell.\n\n1. Run the following git commands using the Cloud Shell terminal:\n\n git config --global user.email \u003cvar translate=\"no\"\u003eyou@example.com\u003c/var\u003e\n git config --global user.name \u003cvar translate=\"no\"\u003eYourName\u003c/var\u003e\n\n2. To check in your change, in the Source Control panel in the\n Cloud Shell Editor, write a commit message and then click\n **Commit** or press\n **Cmd/Ctrl** + **Enter**).\n\nClone a repository\n------------------\n\nTo clone a remote Git repository for use in the Cloud Shell Editor:\n\n1. Retrieve the repository URL: For GitHub repositories, open the main page of your repository and then open the Clone or Download dialog.\n2. Launch the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run **Git: Clone**.\n3. When prompted, enter the Git repository location.\n\nCreate and switching between branches\n-------------------------------------\n\nTo create a new branch or switch to working on an existing branch:\n\n1. Launch the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run **Git: Checkout**.\n2. Select from the list of branches or create a new local branch.\n\nGit status bar\n--------------\n\nThe Git status bar provides a way to keep track of your current branch and\nswitch to another with the branch indicator. It also provides the Synchronize\nChanges action to check for changes between your local repository and your\nupstream branch. Synchronizing changes pushes local changes to your upstream\nbranch and pulls remote changes into your local repository.\n\nIf you don't have an upstream branch set up, the Publish action is available\nto push your local changes to a remote repository."]]