Skip to main content
In this lesson we’ll cover how to start a GitHub Codespace and what happens when one is provisioned. GitHub Codespaces provides cloud-hosted, containerized development environments you can launch from multiple interfaces and stages of the development lifecycle. Codespaces run on virtual machines hosted on Azure and use a devcontainer configuration to deliver a reproducible workspace with the tools, extensions, and runtimes your project needs.
The image is a diagram explaining the process of starting a GitHub Codespace, showing different interfaces (GitHub.com, VS Code, GitHub CLI) and detailing the components involved, like code editors and virtual machine hosting on Azure. It outlines steps to initiate a codespace from templates, branches, pull requests, or commits and describes components such as container environments and supported languages.
What you can do with Codespaces
  • Create a fresh, reproducible development environment for a repository without installing dependencies locally.
  • Connect from the browser, from Visual Studio Code (desktop or web), or manage environments from the terminal using the GitHub CLI.
  • Launch environments that match a repository’s branch, pull request, commit, or template state to ensure deterministic development and testing.
Primary ways to launch and manage a Codespace Example: GitHub CLI snippets
How Codespaces are initialized
  • Templates: Repository templates or starter templates bootstrap a new project. Templates commonly include a .devcontainer folder (with devcontainer.json and an optional Dockerfile) that specifies the container image, required packages, extensions, and forwarded ports.
    Using a .devcontainer codifies the OS image, packages, and editor extensions so every codespace launched from the repo delivers a consistent developer experience.
  • Branch: Launch from a specific branch to develop in the same code and config context as that branch.
  • Pull request: Start a Codespace from a pull request to run the changes in an isolated environment for review and validation.
  • Commit: Create a Codespace tied to a commit hash to reproduce the repository state at a precise point in time—valuable for debugging and regression testing.
Under the hood When you start a Codespace, GitHub provisions an Azure virtual machine and then starts one or more containers defined by the devcontainer configuration. The container image and devcontainer settings determine which languages, runtimes, CLIs, and VS Code extensions are available when the environment starts. This architecture ensures that the development environment is portable, reproducible, and isolated from your local machine. Important considerations
Codespaces availability and billing depend on your GitHub account or organization plan and policies. Verify enabled regions, allowed machine types, and usage quotas in your organization settings before provisioning large or long-running environments.
Quick tips and best practices
  • Add a complete .devcontainer configuration to your repository to lower onboarding friction for contributors.
  • Use lightweight base images for faster spin-up times.
  • Forward only required ports and set workspace-specific secrets via repository or organization settings.
  • Stop or delete idle Codespaces to minimize billing and resource usage.
Links and references

Watch Video