Elena' s AI Blog

GitHub Codespaces

05 Jan 2022 (updated: 29 Dec 2025) / 4 minutes to read

Elena Daehnhardt


Precise version control workflow illustration


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 computer while traveling. My projects require running numerous tests that should run well even on my M1 computer, which at the moment does not have all packages working smoothly together. To be more flexible and independent from any single local development environment, I use GitHub Codespaces. It is a tool so helpful that I do not know how I worked without it.

What Is GitHub Codespaces

GitHub Codespaces is a cloud-hosted development environment that runs in a configurable container attached to a GitHub repository. A codespace environment is created with the help of .devcontainer configuration files added to the repository. To set up a codespace and build your app container, Codespaces must be enabled for your account or organisation. You can create codespace environments for any branch in your GitHub repository once enabled: press the green <> Code button in the GitHub web UI and choose from the default or advanced options. For the full configuration contract, 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, log in to Codespaces over SSH. Personally, I use GitHub tokens to authenticate. The gh auth refresh command adds the codespace scope required for SSH access. See the GitHub CLI manual for all authentication options.

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

Conclusion: GitHub CLI and Codespaces SSH Setup

GitHub Codespaces is a cloud development environment that removes the need for a fully configured local toolchain. We installed the GitHub CLI on macOS with Homebrew, added the codespace authentication scope, and opened an SSH session into a codespace with gh codespace ssh.

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.

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