Skip to main content

Changing the machine type for your codespace

You can change the type of machine that's running your codespace, so that you're using resources appropriate for the work you're doing.

GitHub Codespaces 可用于使用 GitHub Team 或 GitHub Enterprise Cloud 的组织。 GitHub Codespaces 也可作为受限的 beta 版本提供给使用 GitHub Free 和 GitHub Pro 计划的个人用户。 有关详细信息,请参阅“GitHub 的产品”。

About machine types

Note: You can only select or change the machine type if you are a member of an organization using GitHub Codespaces and are creating a codespace on a repository owned by that organization.

通常,你可以在选择的远程机器上运行 codespace,从 2 核到 32 核。 每种类型都有不同的资源水平和不同的计费等级。 有关信息,请参阅“关于 GitHub Codespaces 的计费”。

默认情况下,创建 codespace 时将使用具有最低有效资源的计算机类型。 You can choose an alternative machine type either when you create a codespace or at any time after you've created a codespace.

For information on choosing a machine type when you create a codespace, see "Creating a codespace."

Changing the machine type

Note: 可供选择的计算机类型可能会受为组织配置的策略或存储库的计算机类型最低规范的限制。 有关详细信息,请参阅“限制对计算机类型的访问”和“为代码空间计算机设置最低规范”。

  1. Navigate to the "Your codespaces" page at github.com/codespaces.

    The current machine type for each of your codespaces is displayed.

    'Your codespaces' list

  2. Click the ellipsis (...) to the right of the codespace you want to modify.

  3. Click Change machine type.

    'Change machine type' menu option

  4. If multiple machine types are available for your codespace, choose the type of machine you want to use.

    Dialog box showing available machine types to choose

  5. Click Update codespace.

  1. In VS Code, open the Command Palette with Command+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux).

  2. Search for and select "Codespaces: Change Machine Type."

    Searching for a branch to create a new Codespaces

  3. If you're not following these instructions within a codespace, click the codespace that you want to change.

    Searching for a branch to create a new Codespaces

    If you are following these instructions in a codespace, the change will apply to the codespace you're working in.

  4. Select the machine type you want to use.

  5. If you're changing to a machine type with a different storage capacity, a prompt will appear asking if you would like to continue. Read the prompt and click Yes to accept.

You can use the gh codespace edit --machine MACHINE-TYPE-NAME GitHub CLI command to change the machine type of a codespace. To use this command, you'll first need to find out the available machine types for your codespace.

  1. To view your list of codespaces, in a terminal, enter the following command.

    gh codespace list
    
  2. Optionally, to find the current machine type for a codespace, enter the following command.

    gh api /user/codespaces/CODESPACE-NAME
    

    Replace CODESPACE-NAME with the permanent name of the codespace, for example octocat-myrepo-gmc7. The permanent names are listed under the NAME column in the list returned by gh codespace list.

    If you're prompted to request the codespace scope, follow the instructions in the terminal.

    Details for the current machine are listed under the machine field.

  3. To find the available machine types for a codespace, enter the following command.

    gh api /user/codespaces/CODESPACE-NAME/machines
    

    Replace CODESPACE-NAME with the permanent name of the codespace, for example octocat-myrepo-gmc7.

  4. To change the machine type for a codespace, enter the following command.

    gh codespace edit --machine MACHINE-TYPE-NAME
    

    Replace MACHINE-TYPE-NAME with the name of an available machine type for your codespace, for example standardLinux32gb.

  5. Using the arrow keys, navigate to the codespace you want to change, then press Enter.

If you changed to a virtual machine with a different storage capacity (for example, from 64GB to 32GB), your codespace will be unavailable for a short time while the machine type is changed. If the codespace is currently active, it will automatically be stopped. When the change is complete, you'll be able to restart the codespace running on the new machine type.

If you changed to a virtual machine with the same storage capacity, the change will be applied the next time you restart the codespace. An active codespace will not be stopped automatically. For more information on restarting a codespace, see "Stopping and starting a codespace."

Further reading