Skip to main content

About billing for GitHub Codespaces

Learn about the costs for using GitHub Codespaces, and the monthly usage quotas included with GitHub personal accounts.

Note

2024 年 6 月 2 日之后创建的企业帐户和企业帐户拥有的组织有权访问增强型计费平台。 参与 beta 版本计划的企业也可以访问增强型计费平台。

增强型计费平台能提供更好的支出控制和详细的可见性,通过更精细的控制帮助你了解使用情况。 请参阅“Using the new billing platform”。

About GitHub Codespaces pricing

Note

GitHub 可能会提前对按使用情况计费的成本值应用临时授权保留,这将在帐户的付款方式中显示为待定费用。

GitHub Codespaces 由组织、企业或个人帐户支付。 个人帐户的免费版和专业版计划包括免费使用 GitHub Codespaces,每月有最多固定使用量。

Organizations can choose whether codespaces created from their repositories will be user-owned or organization-owned. See "选择谁拥有组织中的 codespace 并为其付费." An organization pays for a codespace if all the following things are true.

  • The organization has chosen for codespaces to be organization-owned.
  • 组织已为 GitHub Codespaces 设置非零支出限制。
  • codespace 是从组织的一个存储库创建的,或者从组织一个存储库的分支中创建的。 这包括公共、专用和内部存储库。
  • 创建 codespace 的用户是组织的成员或协作者,并且组织为此用户启用了 GitHub Codespaces。 如果组织选择为所有用户启用 Codespaces,可以包括所有成员和协作者。 如果没有为用户启用 Codespaces,他们仍然可以从组织的公共存储库创建 codespace,但用户将为这些 codespace 付费。

For more information about enabling GitHub Codespaces for users, see "为组织启用或禁用 GitHub Codespaces."

Otherwise use of GitHub Codespaces applies to the personal account of the person who created the codespace, and either consumes some of the monthly included usage for their personal account, or their account is billed according to their usage in excess of their included quotas.

The Free, Team, and Enterprise plans for organization and enterprise accounts do not include any free use of GitHub Codespaces.

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

Pricing for paid usage

A GitHub Codespaces instance (a "codespace") incurs charges for compute time, while it is active, and for the amount of disk space the codespace occupies, while it exists. The compute cost is proportional to the number of processor cores in the machine type you choose for your codespace, as shown in the following table. For example, the compute cost of using a codespace for an hour on a 16-core machine is eight times greater than a 2-core machine.

ComponentMachine typeUnit of measureIncluded usage multiplierPrice
Codespaces compute2 core1 hour2$0.18
Codespaces compute4 core1 hour4$0.36
Codespaces compute8 core1 hour8$0.72
Codespaces compute16 core1 hour16$1.44
Codespaces compute32 core1 hour32$2.88
Codespaces storageStorage1 GB-monthNot applicable$0.07

For more information about the GB-month unit of measure, see "About billing for storage usage."

If you enable prebuilding of codespaces this will incur additional charges. See "About billing for Codespaces prebuilds."

About your bill for GitHub Codespaces

GitHub Codespaces is billed in US dollars (USD) according to the amount of compute time and storage space your codespaces use. 始终按月计算 GitHub Codespaces 的费用,即使你的帐户按年计费也是如此。

Billing for GitHub Codespaces shares your account's existing payment method, and receipt. See "Viewing your subscriptions and billing date."

If you are an organization owner or enterprise owner, you can connect an Azure Subscription ID to your organization or enterprise account to enable and pay for GitHub Codespaces usage. See "连接 Azure 订阅."

About billing for compute usage

The compute usage of a codespace is the length of time for which that codespace is active multiplied by the multiplier in the pricing table for the machine type of the codespace. Total compute usage is calculated by summing the time used by all codespaces billable to a particular account. These totals are reported to the billing service every hour, and are billed monthly.

As an example, if a codespace is active for 1 hour and 15 minutes, then the compute cost will be the hourly cost of the codespace, as determined by its machine type, multiplied by 1.25.

You can control compute usage by stopping your codespaces. For information, see "停止和启动 codespace." Codespaces are stopped automatically after a configurable period of inactivity. The timeout period can be configured by the user, or at the organization level. See "设置 GitHub Codespaces 超时期限" and "限制空闲超时期限."

About billing for storage usage

For GitHub Codespaces billing purposes, storage comprises the disk space used by all of the codespaces and prebuilds in your account. This includes any files you use in a codespace, such as cloned repositories, configuration files, data loaded to the codespace (for example as input or output of the software running in the repository), and extensions, among others. Storage is billed for all of your existing codespaces, regardless of whether they are active or inactive with the exception of blocked usage due to exhausted included usage quota or reaching your spending limit. The storage billing for a codespace ends when it is deleted. However, deleting a codespace does not reduce your used storage amount for the current billing month as this is a cumulative figure.

Note

When you use the default dev container configuration, your dev container will be built from the default Linux image for codespaces. See "开发容器简介." Containers based on the default image are not counted as used storage, irrespective of whether you have added features in your dev container configuration. See "向 devcontainer.json 文件添加功能."

If you use the default image, the storage usage for your codespace will be based on the files in your repository, and any files you subsequently add to the codespace. If you use an alternative base image, then the resulting container and all of the files in the codespace will be counted as used storage.

有关如何检查是否从默认开发容器映像生成 codespace 的信息,请参阅“充分利用包含的使用量”。

Codespace storage is reported in GB-months. Your billing month runs from a fixed day in one month until the same day in the next month. In most cases the day of the month is determined by the day you started on your current GitHub plan. Your GB-month storage is calculated as follows. Once every hour, the storage used by all of your currently active and stopped codespaces is assessed. This figure is then divided by the number of hours in the current billing month: total storage size / hours this month. The result is added to the running total for codespace storage for the month.

For example, if you have one codespace that uses 100 GB of storage and has existed for one hour you will have used 100 / (24 * 30) = 0.1388 GB-months of storage in a 30-day month. If your use of GitHub Codespaces during a 30-day month consists of two 100 GB codespaces that both existed for three full days then there will be 24 * 3 hourly reports for the storage of these codespaces, giving a total of (24 * 3) * 200 / (24 * 30) = 20 GB-months.

For each hourly report, the storage usage for the previous hour is calculated in seconds. As a result, you won't be charged for a full hour of storage if a codespace did not exist for the full 60 minutes. At the end of the month, GitHub rounds your storage to the nearest MB.

Organization owners can:

  • List the currently active and stopped codespaces for your organization. See "列出组织中的 codespace." In addition to the cost of these codespaces, the cost of GitHub Codespaces for the current month may include costs for codespaces that existed earlier in the current month but have since been deleted.
  • See the total GitHub Codespaces compute and storage usage for your organization for the current month to date. See "Viewing your GitHub Codespaces usage."
  • Configure your organization settings to manage the cost of GitHub Codespaces. See "管理组织中的 GitHub Codespaces 成本."

To estimate the costs for usage-based billing, you can use the GitHub pricing calculator.

About billing for Codespaces prebuilds

预生成为存储库、分支和 devcontainer.json 配置文件的特定组合组装 codespace 的主要组件。 它提供了一种快速创建新 codespace 的方法。 特别是对于复杂和/或大型的存储库,你可以使用预生成更快地创建新 codespace。 See "关于 GitHub Codespaces 预生成."

GitHub Actions costs for prebuilds

Prebuilds are created and updated by running a GitHub Actions workflow on a GitHub-hosted runner. You can configure how you want prebuild updates to be automatically triggered. For information, see "配置预生成."

As with other workflows, while prebuild workflows are running they consume GitHub Actions minutes included with your account, if you have any, or they incur charges for GitHub Actions minutes. For more information about pricing for GitHub Actions minutes, see "About billing for GitHub Actions." There is no associated Codespaces compute cost for creating or updating prebuilds.

You can track usage of prebuild workflows and storage by downloading a usage report for your account. See "Viewing your GitHub Codespaces usage."

Storage costs for prebuilds

In addition to GitHub Actions minutes, you will also be billed for the storage of prebuilds associated with each prebuild configuration, for a given repository and region. Storage of prebuilds is billed at the same rate as storage of codespaces.

The storage cost for a prebuild in a single region will be similar to the storage cost that will be incurred for storing a single codespace created from that prebuild. The storage cost for the generated codespace may be more than the cost for the prebuild if, for example, the updateContentCommand and postCreateCommand commands are used during codespace creation to download more files to the dev container.

The total storage costs associated with a prebuild configuration will depend on the following factors.

  • The price of storage per GB (see the table earlier in this article)
  • The size of the generated prebuild in GB
  • The number of regions in which the prebuild is available (because a copy of the prebuild is stored in each region)
  • The number of older versions of the prebuild that are retained

The storage cost for the prebuilds generated by a prebuild configuration is therefore calculated as: price per GB * size (GB) * regions * versions.

You can check how many GB-months of storage has been used by prebuilds by reviewing the current billing data for your personal or organization account. See "Viewing your GitHub Codespaces usage."

如果为分支存储库创建预生成,则这些预生成的存储成本将从每月包含的存储中减去(如有)。 如果已使用完所有包含的存储,并且已设置计费,则会对个人帐户进行收费。 即使为分支创建的 codespace 是由拥有父存储库的组织支付,也是如此。 See "How billing is handled for forked repositories."

Controlling the cost of prebuilds

To reduce consumption of Actions minutes, you can set a prebuild to be updated only when you make a change to your dev container configuration files, or only on a custom schedule. You can also manage your storage usage by adjusting the number of previous versions of each prebuild that are retained. See "配置预生成."

To limit the storage costs associated with prebuilds, you can choose to create prebuilds only in selected regions, and you can specify the number of older versions of prebuilds that will be retained. See "配置预生成."

If you delete a prebuild configuration, all the associated prebuilds are deleted, reducing your storage consumption from that point onward. See "管理预生成."

Notes:

  • Prebuilds may be updated several times during a billing month. Newer versions of a prebuild may be larger or smaller than the previous versions. This will affect the storage charges. For details of how storage is calculated during a billing month, see "About billing for storage usage" earlier in this article.
  • As with deleting codespaces, deleting prebuilds does not reduce your used storage amount for the current billing month as this is a cumulative figure.

Cost of codespaces created from prebuilds

Use of codespaces created using prebuilds is charged at the same rate as regular codespaces.

Setting a spending limit

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

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

For information on managing and changing your account's spending limit, see "Managing the spending limit for GitHub Codespaces."

如果个人、组织或企业帐户达到其支出限制,则无法再创建或恢复可向该帐户计费的 codespace。 但你仍然可以将任何正在进行的更改导出到新分支。 有关详细信息,请参阅“将更改导出到分支”。

Viewing projected usage for an organization

Organization owners and billing managers can view an estimated total usage cost for GitHub Codespaces for the organization, for the current monthly billing cycle. See "Viewing your GitHub Codespaces usage."

The projected usage shown on the billing page for an organization is calculated based on the total cost for Codespaces compute and storage usage incurred during the previous seven days, prior to the current day. This is projected forward for the remainder of the billing month to give you an idea of how much the total cost might be for the current billing cycle.

The calculation used for this estimate is:

<cost for the previous 7 full days>/7 * <days remaining in the billing month, including the current day> + <cost already accrued in this billing month>

The projected usage does not take into account information such as whether GitHub Codespaces is still enabled, the number or size of codespaces that currently exist, or your prebuild settings. For this reason, if all of the organization's codespaces and prebuilds were deleted today, the projected usage for the billing month would still show a figure higher than the accrued usage. However, after seven days have elapsed, with no further Codespaces usage, the projected usage will be the same as the currently accrued usage.

Limiting the machine types for organization-owned codespaces

By default the machine type with the lowest valid resources is used when a codespace is created. However, users may be able to choose a machine type with more resources. They can do this either when they create a codespace, or they can change the machine type of an existing codespace. See "为存储库创建 codespace" and "更改代码空间的计算机类型."

If a machine type that has more resources is chosen, this will affect the per-hour charge for that codespace, as shown in the table earlier in this article.

Organization owners can create a policy to limit the choice of machine types available to users for codespaces that are billed to an organization or enterprise account. See "限制对计算机类型的访问."

Limiting the number of organization-owned codespaces

Organization owners can limit the number of codespaces that people can create, where the organization will be billed for the codespace. This can help to reduce storage charges for the organization. See "限制用户可以创建的向组织计费的 codespace 数量."

How billing is handled for forked repositories

Usage of codespaces created from a forked repository will be billed to your personal account unless the upstream (or parent) repository is in an organization that has allowed you - as a member, or outside collaborator, of the organization - to use codespaces at the organization's expense.

For example, consider a member, or outside collaborator, of an organization that has allowed billing for codespaces for that user. If the user has permission to fork an organization-owned private repository, they can subsequently create and use a codespace for the new repository at the organization's expense. This is because the organization is the owner of the parent repository. Note that the organization owner can remove the user's access to the private repository, the forked repository, and therefore also the codespace. The organization owner can also delete the parent repository which will also delete the forked repository. See "管理仓库的复刻政策."

如果为分支存储库创建预生成,则这些预生成的存储成本将从每月包含的存储中减去(如有)。 如果已使用完所有包含的存储,并且已设置计费,则会对个人帐户进行收费。 即使为分支创建的 codespace 是由拥有父存储库的组织支付,也是如此。

How billing is handled when a repository is transferred to another organization

Usage is calculated every hour. An organization pays for usage of codespaces created from any repository owned by the organization, where the organization settings permit the organization to be billed. See "选择谁拥有组织中的 codespace 并为其付费." When a repository is transferred out of your organization, ownership and billing responsibility for any codespaces associated with that repository will change accordingly.

How billing is handled for GitHub Codespaces templates

You can get started on a new project by creating a codespace from a template. Codespaces created from templates aren't initially associated with a repository, but you can publish the codespace to a repository owned by your personal account. See "通过模板创建 codespace."

Any organization can maintain a template repository for use with GitHub Codespaces. As with any other repository in an organization, a codespace created from a template repository is billed to the organization if the organization has set a spending limit for GitHub Codespaces and allowed the user creating the codespace to do so at the organization's expense. Otherwise, the codespace is billed to the user who creates the codespace.

If a user publishes a codespace created from a template, the codespace is published to a new repository owned by the user's personal account. If the codespace is currently billed to an organization, ownership and billing of the codespace transfer to the user who created the codespace.

Note: A 托管用户帐户 cannot be the billable owner of a codespace. Therefore:

  • A 托管用户帐户 can only create a codespace from a template if the codespace is billed to an organization.
  • A 托管用户帐户 cannot publish a codespace created from a template to a new repository.

See "关于 Enterprise Managed Users."

What happens when users are removed

If a user is removed from an organization or repository, their codespaces are automatically deleted.