AI
Creating a Codespace for a repository: steps, options and what happens behind the scenes
How to create a Codespace from GitHub, VS Code or the CLI, the four creation stages, machine type and devcontainer options, and who pays.
Last reviewed:
The idea
A codespace is a cloud development environment tied to a specific branch of a repository. You can create it on GitHub, in VS Code or with the GitHub CLI, and edit, debug and use Git inside it.
Creating from GitHub
- Open the repository's main page.
- Pick the branch from the dropdown.
- Click Code, then the Codespaces tab; a message at the bottom tells you who will pay for the codespace.
- Create it with defaults, or choose New with options to set a machine type or a particular devcontainer.json file.
The four creation stages
- A VM and storage are assigned.
- The container is created and the repository is cloned.
- You can connect to the codespace.
- Post-creation setup continues.
A point for Git hooks users
The doc says the codespace's container is created after the repository is cloned, so a git template directory set in the image does not apply. Install hooks through devcontainer.json lifecycle scripts such as postCreateCommand, which run in stage 4.
Ownership and billing
For personal accounts there is a monthly free quota on Free and Pro plans; beyond it you need payment details and a spending limit. Organizations can let members create codespaces at the organization's expense, and your ability to create from org-owned repositories depends on repository visibility and org settings. I did not read the quota numbers here.
Common mistakes
- Trying to create from an empty branch.
- Ignoring the who-will-pay message before creating.
- Expecting git hooks from the container image to work.
- Leaving old codespaces around; they are listed on the Your codespaces page.
Latest updates
The first part of the guide (through creating from GitHub) was read on 2026-11-30. I did not read the VS Code and CLI tabs or the billing page.
Similar tools
For the overview read Codespaces, for automation read GitHub Actions, for publishing read GitHub Pages.
Not verified
The VS Code and GitHub CLI tabs, the free quota numbers and the prebuilds page were not read.
Related pages
Sources
Wording is ours, from the official source. Images and video belong to their owners and are credited with a link to the official page.