Skip to main content

Deleting a codespace

You can delete a codespace you no longer need.

GitHub Codespaces is available for organizations using GitHub Team or GitHub Enterprise Cloud. GitHub Codespaces is also available as a limited beta release for individual users on GitHub Free and GitHub Pro plans. For more information, see "GitHub's products."

There are costs associated with storing codespaces. You should therefore delete any codespaces you no longer need. For more information, see "About billing for GitHub Codespaces."

There are limits to the number of codespaces you can create, and the number of codespaces you can run at the same time. These limits vary based on a number of factors. If you reach the maximum number of codespaces and try to create another, a message is displayed telling you that you must remove an existing codespace before you can create a new one.

Deleting a codespace

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

  2. To the right of the codespace you want to delete, click , then click Delete

    Delete button

You can delete codespaces from within VS Code when you are not currently working in a codespace.

  1. In VS Code, in the left sidebar, click the Remote Explorer icon.

    The Remote Explorer icon in Visual Studio Code

    Note: If the Remote Explorer is not displayed in the Activity Bar:

    1. Access the Command Palette. For example, by pressing Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux).
    2. Type: codespaces.
    3. Click Codespaces: Details.
  2. Under "GITHUB CODESPACES", right-click the codespace you want to delete.

  3. Click Delete Codespace.

    Deleting a codespace in GitHub

To learn more about GitHub CLI, see "About GitHub CLI."

To delete a codespace use the gh codespace delete subcommand and then choose a codespace from the list that's displayed.

gh codespace delete

If you have unsaved changes, you'll be prompted to confirm deletion. You can use the --force flag to force deletion, avoiding this prompt.

For more information about this command, see the GitHub CLI manual.

Bulk deleting codespaces

You can use GitHub CLI to delete several or all of your codespaces with a single command. For more information, click the GitHub CLI tab near the top of this page.

You can use GitHub CLI to delete several or all of your codespaces with a single command. For more information, click the GitHub CLI tab near the top of this page.

You can delete several or all of your codespaces with a single command, using gh codespace delete followed by one of these flags:

--all - Delete all of your codespaces.

--repo REPOSITORY - Delete all of your codespaces for this repository. Or use together with the --days flag to filter by age of the codespace.

--days NUMBER - Delete all of your codespaces that are older than the specified number of days. Can be used together with the --repo flag.

By default you are prompted to confirm deletion of any codespaces that contain unsaved changes. You can use the --force flag to skip this confirmation.

Example

Delete all of the codespaces for the octo-org/octo-repo repository that you created more than 7 days ago.

gh cs delete --repo octo-org/octo-repo --days 7

Deleting codespaces in your organization

As an organization owner, you can use GitHub CLI to delete any codespace in your organization.

For more information, click the "GitHub CLI" tab near the top of this page.

For more information, click the "GitHub CLI" tab near the top of this page.

  1. Enter one of these commands to display a list of codespaces.

    • gh codespace delete --org ORGANIZATION - Lists the current codespaces in the specified organization.
    • gh codespace delete --org ORGANIZATION --user USER - Lists only those codespaces created by the specified user. You must be an owner of the specified organization.
  2. In the list of codespaces, navigate to the codespace you want to delete.

  3. To delete the selected codespace press Enter.

    If the codespace contains unsaved changes you will be prompted to confirm deletion.

You can also use the REST API to delete codespaces for your organization. For more information, see "Codespaces organizations."

Further reading