Getting Started with GitHub Codespaces on VS Code
Tags: tutorial, githubhack23, webdev, productivity
Published: 2023-05-14 14:29:11

**GitHub codespaces are one of the best development environments for developers. From a faster development environment to having access to a remote Linux environment, it's a workspace for all. 
In this tutorial, I will be teaching you one of the many ways to use GitHub codespaces. Let's get started.**

## What are GitHub codespaces?
Before we get started with the tutorial, let's get to know more about GitHub codespaces and their features.

**GitHub codespaces** are development environments hosted in the cloud. It allows users to configure these environments according to their needs. Some of the configuration options include setting up the bash terminal, runtimes for popular languages like Python, PHP, and Node, git for version control, yarn for package installation, e.t.c.

**GitHub codespaces** run on dedicated virtual machines ranging from 2 cores to up to 32 cores. Users can connect to their codespaces from the browser or locally using IDEs like VS Code and JetBrains. Users get up to 60 hours of free usage every month.

## Setting up VS Code as the default editor for GitHub codespaces

By default, when creating a new codespace, it opens in the VSCode web client. To open codespaces in your locally installed VS Code, you need to install the GitHub Codespaces extension for Visual Studio Code.

You can install GitHub codespaces [here](https://marketplace.visualstudio.com/items?itemName=GitHub.codespaces) by clicking the install button on the page. Note that you must have Visual Studio Code installed locally for the install button to redirect you to VS Code.

**Once you've installed the extension, you can now follow the following steps to set VS Code as your default editor for GitHub codespaces:**

- Visit [GitHub](https://github.com) and make sure you're signed in to your account.

- Click your profile photo in the upper-right corner of any page.

![Clicking GitHub profile photo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cb4e1xieejuzp7pzfaby.jpg)

- Then click Settings from the drop-down menu.

![Clicking settings from GitHub profile drop down menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9q3qjuxemjht8w7n32j.jpg)

- In the left sidebar, scroll down and find the "Code, planning, and automation" section. Then click Codespaces.

![Clicking codespaces on the left sidebar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbtyl8lr7dlj5y5npt21.jpg)

- Scroll down and find the "Editor preference" section. Then select Visual Studio Code.

![Selecting VS Code in the Editor preference section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cyszommvaaf7ptlvde6.jpg)

GitHub codespaces will now open on the VS Code desktop application when you next create or open a codespace.

## Configuring VS Code for GitHub Codespaces

**Before we get started creating our own codespace in VS Code, you will need to sign into the GitHub codespace using your GitHub credentials:**

- Open VS Code, and in the Activity Bar, click the "Remote Explorer" icon.

![Clicking remote explorer in VS Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmtl9fgvmx2mg3kjt5xi.jpg)

-  At the top of the "Remote Explorer", you will see a dropdown menu. Select "GitHub Codespaces" from the dropdown.

![Selecting GitHub codespaces from the dropdown menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ije0cy15hgcy995xx8vz.jpg)

- Click on the "Sign in to GitHub" button.

![Signing into GitHub for GitHub Codespace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7vtx2t3dc3l8hhpbteg.jpg)

- You'll be prompted to sign in if you are not currently signed in to GitHub. Follow other instructions until you're back on the remote explorer again.

![Signed in to codespace with GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fe3faowla1or2wd1aamv.jpg)

You're now signed in to GitHub codespaces.

## Creating a GitHub Codespace in VS Code

**Now that we've setup GitHub codespaces for VS Code, let's create a new codespace:**

- Click the "Remote Explorer" icon

![Clicking remote explorer in VS Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmtl9fgvmx2mg3kjt5xi.jpg)

- Use your mouse to hover over the remote explorer panel. Then click the "+" icon.

![Clicking the + icon to create a codespace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1q8bpyfebcckev926mf.jpg)

- A text box and a list of your repositories will be displayed. Type and select the repo name you want to create the codespace for.

![Selecting repo for codespace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4078ybsmlsj4uimokyn.jpg)

You will be prompted to select a branch and a machine type. Go ahead and select your preferred settings.

You can now start to develop in the codespace in VS Code

## Opening a GitHub Codespace in VS Code

- Click the "Remote Explorer" icon.
- In the "GitHub Codespaces" panel, hover over the codespace and select the plug icon to connect to the codespace.

![Clicking the plug icon to connect to a codespace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rs2ahvfs6rj7u3o36kbk.jpg)

You can now enjoy developing in your codespace.