[[["容易理解","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,["# Version control with Cloud Workstations\n\nThis page describes how to use version control for your application files with\nthe Cloud Workstations base editor's Git support.\n\nClick **Source Control** from the Activity bar to\ncreate a new Git repository, access your existing Git repositories, view\nexisting and staged changes, or merge changes.\n\nFrom here, you can stage and unstage changes, diff between the previous state\nand the current version of files, and commit changes, all from within the base 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,\nyou must authenticate with Git.\n\nWhen you carry out an action that requires authentication, Git prompts you for a\npassword. Enter a personal access token (PAT), which is a more secure\nalternative to Git passwords. 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)\nguide.\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 Workstations base 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 Workstations base editor. To toggle between your repositories, in the\nCloud Workstations base editor status bar, click your repository name. From the\nmenu, select the repository to switch your scope to.\n\nThis updates your Source Control: Git 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: Git 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: Git 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\nCloud Workstations.\n\n1. Run the following git commands using the Cloud Workstations terminal.\n Be sure to update the email and name with your data:\n\n git config --global user.email \u003cvar translate=\"no\"\u003ealex@example.com\u003c/var\u003e\n git config --global user.name \u003cvar translate=\"no\"\u003eAlex\u003c/var\u003e\n\n2. To check in your change, in the Source Control: Git panel in the base\n editor, write a commit message and then click check_box**Commit** or press \u003ckbd\u003eControl+Enter\u003c/kbd\u003e (or\n \u003ckbd\u003eCommand+Enter\u003c/kbd\u003e on mac OS).\n\nClone a repository\n------------------\n\nTo clone a remote Git repository for use in the Cloud Workstations base 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. To open the command palette, press \u003ckbd\u003eControl+Shift+P\u003c/kbd\u003e (or \u003ckbd\u003eCommand+Shift+P\u003c/kbd\u003e on macOS), or click **View** \\\u003e **Command Palette**.\n3. Run **Git: Clone**.\n4. 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. To open the command palette, press \u003ckbd\u003eControl+Shift+P\u003c/kbd\u003e (or \u003ckbd\u003eCommand+Shift+P\u003c/kbd\u003e on macOS), or click **View** \\\u003e **Command Palette**.\n2. Run **Git: Checkout**.\n3. 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."]]