DEV Community

Code with GitHub Codespaces

Introduction : GitHub Codespaces is a fully configured development environment hosted in the cloud. By using GitHub Codespaces, your workspace, along with all of your configured development environments, is available from any computer with access to the internet.

GitHub Codespaces is an instant, cloud-based development environment that uses a container to provide you with common languages, tools, and utilities for development.

The Codespace lifecycle

Image description

  • GitHub Codespaces is configurable, allowing you to create a customized development environment for your project.

  • A Codespace's lifecycle begins when you create a Codespace and ends when you delete it. You can disconnect and reconnect to an active Codespace without affecting its running processes.

  • You can stop and restart a Codespace without losing the changes that you make to your project.

Create a Codespace
You can create a Codespace on GitHub.com, in Visual Studio Code, or by GitHub CLI. There are four ways to create a Codespace:

  • From a GitHub template or any template repository on GitHub.com to start a new project.
  • From a branch in your repository for new feature work.
  • From an open pull request to explore work-in-progress.
  • From a commit in a repository's history to investigate a bug at a specific point in time.

Codespace creation process

Image description

When you create a GitHub Codespace, four processes occur:

  • VM and storage are assigned to your Codespace.
  • A container is created.
  • A connection to the Codespace is made.
  • A post-creation setup is made.

Few other options we can do with codespaces
Save changes in a Codespace :

  • When you connect to a Codespace through the web, AutoSave is automatically enabled to save changes after a specific amount of time has passed.
  • When you connect to a Codespace through Visual Studio Code running on your desktop, you must enable AutoSave.

Open an existing Codespace : You can reopen any of your active or stopped Codespaces on GitHub.com, in a JetBrains IDE, in Visual Studio Code, or by using GitHub CLI.

Timeouts for a Codespace: If a Codespace is inactive, or if you exit your Codespace without explicitly stopping, the application times out after a period of inactivity and stops running.

*Internet connection while using GitHub Codespaces *: A Codespace requires an internet connection. If the connection to the internet is lost while working in a Codespace, you won't be able to access your Codespace.

Close or stop a Codespace If you exit the Codespace without running the stop command (for example, by closing the browser tab) or leave the Codespace running without interaction, the Codespace and its running processes continue during the inactivity timeout period.

Rebuild a Codespace : You can rebuild your Codespace to implement changes to your dev container configuration. For most uses, you can create a new Codespace as an alternative to rebuilding a Codespace.

Delete a Codespace : You can create a Codespace for a particular task. After you push your changes to a remote branch, then you can safely delete that Codespace.

Conclusion:
πŸ’¬ If you enjoyed reading this blog post and found it informative, please take a moment to share your thoughts by leaving a review and liking it πŸ˜€ and follow me in dev.to , linkedin

Top comments (0)