Elena' s AI Blog

GitHub Codespaces

05 Jan 2022 (updated: 06 Aug 2026) / 5 minutes to read

Elena Daehnhardt


Flux: A developer's laptop screen showing a cloud-hosted code editor connected by a glowing line to a distant server icon i...


TL;DR:
  • Use GitHub Codespaces for cloud development: click 'Code' button, choose Codespace. Configure with .devcontainer files. Access from any device—no local setup needed. Perfect for team collaboration.

Previous: Part 18 — Should you use rebase?

Next: Part 20 — Linters and Git Pre-commit

Why Use GitHub Codespaces for Cloud Development

I use two computers for my coding projects and take only one with me when I travel. My projects run a lot of tests, and I want them to work reliably even on my M1 Mac, where not every package plays nicely together yet. To stop depending on any single local setup, I use GitHub Codespaces. It is a tool so helpful that I no longer remember how I worked without it.

What Is GitHub Codespaces

GitHub Codespaces is a cloud-hosted development environment: GitHub runs it in a Docker container on a virtual machine, and you connect from your browser, VS Code, or the terminal. You configure it with .devcontainer files added to the repository — skip them, and GitHub falls back to a default Ubuntu image with a broad set of languages and tools already installed. If you’re on a personal GitHub Free or Pro plan, there’s nothing to switch on: everyone gets a monthly free quota of Codespaces usage automatically. Organisation owners are the exception — they may need to turn Codespaces access on for the org’s private repositories first. Either way, you create a codespace for any branch by pressing the green <> Code button in the GitHub web UI and choosing from the default or advanced options. For the full configuration reference, see the GitHub Codespaces documentation.

Installing GitHub CLI with Homebrew for SSH Access

GitHub CLI (gh) is the official command-line interface for GitHub that lets you authenticate and open an SSH session into a codespace from the terminal. Homebrew is the package manager for macOS used here to install gh. First, if Homebrew is not yet installed, download it from https://brew.sh or run the install command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Next, install the GitHub CLI:

brew install gh

Next, authenticate the CLI and pick up the scope SSH needs. I use a personal access token when gh auth login asks how I want to authenticate. gh auth refresh then extends that token’s scopes without starting a fresh login — here it adds the codespace scope, which SSH access requires. Once that’s done, gh codespace ssh lets you pick a running codespace and drops you straight into a terminal inside it. See the GitHub CLI manual for all authentication options.

gh auth login
gh auth refresh -h github.com -s codespace
gh codespace ssh

Final Thoughts

GitHub Codespaces removes the excuse of “my laptop can’t handle this” — the toolchain lives in the cloud, not on your M1. You’ve now got gh installed via Homebrew, the codespace scope on your token, and a one-line route into an SSH session inside any codespace you spin up. That’s really all the ceremony there is to it.

GitHub Codespaces FAQ

How do I create a GitHub Codespace?

Press the green <> Code button on your GitHub repository page, open the Codespaces tab, and choose Create codespace on main (or pick a branch). Codespaces must be enabled for your account or organisation first.

How do I connect to a GitHub Codespace over SSH from the terminal?

Install the GitHub CLI (brew install gh), authenticate with gh auth login, add the codespace scope with gh auth refresh -h github.com -s codespace, then run gh codespace ssh.

Do I need a local development environment to use GitHub Codespaces?

No. A GitHub Codespace runs in the cloud, so the toolchain, dependencies, and runtime live on a remote container defined by your .devcontainer configuration. You can connect from any device with a browser or the GitHub CLI.

References

Did you like this post? Please let me know if you have any comments or suggestions.

Posts about development tools and Python coding

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2022) 'GitHub Codespaces', daehnhardt.com, 05 January 2022. Available at: https://daehnhardt.com/blog/2022/01/05/edaehn-github-codespace-pycharm/
All Posts