Skip to main content

What are GitHub Codespaces?

Learn about what GitHub Codespaces are.

Note

GitHub Codespaces 在 GHE.com 的子域(例如 octocorp.ghe.com)上不可用。

Introduction

A codespace is a development environment that's hosted in the cloud. You can customize your project for GitHub Codespaces by committing configuration files to your repository (often known as Configuration-as-Code), which creates a repeatable codespace configuration for all users of your project. See 开发容器简介.

Each codespace you create is hosted by GitHub in a Docker container, running on a virtual machine. You can choose from a selection of virtual machine types, from 2 cores, 8 GB RAM, and 32 GB storage, up to 32 cores, 64 GB RAM, and 128 GB storage.

By default, the codespace development environment is created from an Ubuntu Linux image that includes a selection of popular languages and tools, but you can use an image based on a Linux distribution of your choice and configure it for your particular requirements. Regardless of your local operating system, your codespace will run in a Linux environment. Windows and macOS are not supported operating systems for the remote development container.

You can connect to your codespaces from your browser, from Visual Studio Code, or by using GitHub CLI. When you connect, you are placed within the Docker container. You have limited access to the outer Linux virtual machine host.

Diagram showing the relationship between a code editor and a codespace running on an Azure virtual machine.

Using GitHub Codespaces

To begin developing using cloud-based compute resources, you can create a codespace from a template or from any branch or commit in a repository. When you create a codespace from a template, you can start from a blank template or choose a template suitable for the work you're doing.

若要开始使用 GitHub Codespaces,请参阅“Quickstart for GitHub Codespaces”。 有关创建 codespace 的详细信息,请参阅“为存储库创建 codespace”或“通过模板创建 codespace”。 如果要返回到已创建的 codespace,请参阅“打开现有 codespace”。 若要详细了解 GitHub Codespaces 的工作原理,请参阅“Deep dive into GitHub Codespaces”。

Using codespaces owned by your personal account

All personal GitHub accounts have a monthly quota of free use of GitHub Codespaces included in the Free or Pro plan. You can get started using GitHub Codespaces on your personal account without changing any settings or providing payment details.

If you create a codespace from an organization-owned repository, use of the codespace will either be charged to the organization (if the organization is configured for this), or to your personal account.

通过提供付款详细信息和设置支出限制,可以在超出每月包含的存储空间和计算使用量后继续使用 GitHub Codespaces。 请参阅“关于 GitHub Codespaces 的计费”。

Note

GitHub Codespaces 不适用于托管用户帐户拥有的存储库。 有关详细信息,请参阅“关于 Enterprise Managed Users”。

Using organization-owned codespaces

Owners of organizations on GitHub Team and GitHub Enterprise plans can pay for their members' and collaborators' use of GitHub Codespaces. This applies to codespaces created from repositories owned by the organization. See 选择谁拥有组织中的 codespace 并为其付费. You can set a spending limit for use of GitHub Codespaces on your organization or enterprise account. See 管理 GitHub Codespaces 的支出限制.

If use of a codespace will be billed to an organization or enterprise, this is shown when the codespace is created. See 为存储库创建 codespace. Codespaces that are billed to an organization, or its parent enterprise, are owned by the organization and can be deleted by an organization owner. See 删除代码空间.

能否从组织拥有的存储库创建 codespace 取决于多个因素,包括存储库的可见性以及组织或其父企业的设置。 有关详细信息,请参阅“codespace 的创建和删除故障排除”。

Customizing GitHub Codespaces

To customize the runtimes and tools in your codespace, you can create one or more dev container configurations for your repository. Adding dev container configurations to your repository allows you to define a choice of different development environments that are appropriate for the work people will do in your repository.

If you create a codespace from a repository without any dev container configurations, GitHub Codespaces will clone your repository into an environment with the default dev container image that includes many tools, languages, and runtime environments. If you create a codespace from a template, you might start with some initial configuration on top of the default image. See 开发容器简介.

You can personalize aspects of your codespace environment by using a public dotfiles repository. You can use dotfiles to set shell aliases and preferences, or to install your personal preference of the tools you like to use. If you use GitHub Codespaces in the browser, or in Visual Studio Code, you can use Settings Sync to give your codespace editor the same settings, keyboard shortcuts, snippets, and extensions that you have set up in your local installation of Visual Studio Code.

See 自定义代码空间.

Billing for Codespaces

For information on pricing, storage, and usage for GitHub Codespaces, see 关于 GitHub Codespaces 的计费.

Note

必须为个人、组织或企业帐户设置非零支出限制,然后才能向帐户对 GitHub Codespaces 的使用进行计费。

默认情况下,所有帐户的 GitHub Codespaces 支出限制为 0 美元。 这可以防止创建新的 codespace 或打开现有 codespace,如果执行这些操作,将对个人、组织或企业帐户产生可计费成本。 对于个人帐户,如果你有权创建 codespace,只要帐户还没有达到其每月包含的使用量限制,就可以执行此操作。 对于组织和企业,默认支出限制意味着,要允许用户创建向组织或其父企业计费的 codespace,必须将限制更改为高于 0 美元的值。

始终按月计算 GitHub Codespaces 的费用,即使你的帐户按年计费也是如此。 For information on how organizations owners and billing managers can manage the spending limit for GitHub Codespaces for an organization, see 管理 GitHub Codespaces 的支出限制.