| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Create workflows that enable you to use Continuous Integration (CI) for your projects.
GitHub Codespaces is a development environment that's hosted in the cloud.
Welcome to "Develop code using GitHub Codespaces and Visual Studio Code"! 👋
What's the big deal about using a codespace for software development? A codespace is a development environment that's hosted in the cloud. You can customize your project for GitHub Codespaces by committing configuration files to your repository (also known as configuration-as-code), which creates a repeatable codespace configuration for all users of your project. Each codespace you create is hosted by GitHub in a Docker container that runs on a virtual machine. You can choose the type of machine you want to use depending on the resources you need.
GitHub offers a range of features to help your development team customize a codespace to reach peak configuration and performance needs. For example, you can:
To begin developing using GitHub Codespaces, you can create a codespace from a template or from any branch or commit in a repository. When you create a codespace from a template, you can start from a blank template or choose a template suitable for the work you're doing.
We recommend opening another browser tab to work through the following activities so you can keep these instructions open for reference.
Start from the landing page of your repository.
Click the green Code button located in the middle of the page.
Select the Codespaces tab in the box that pops up and then click the Create codespace on main button.
Wait about 2 minutes for the codespace to spin itself up. Note: It's a virtual machine spinning up in the background.
Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below:

<h1>Hello from the codespace!</h1>
Note: The file should autosave.
git commit -a -m "Adding hello from the codespace!"
git push
Nice work! 🎉 You created your first codespace and pushed code using VS Code!
You can configure the development container for a repository so that any codespace created for that repository will give you a tailored development environment, complete with all the tools and runtimes you need to work on a specific project.
What are development containers? Development containers, or dev containers, are Docker containers that are specifically configured to provide a fully featured development environment. Whenever you work in a codespace, you are using a dev container on a virtual machine.
A dev container file is a JSON file that lets you customize the default image that runs your codespace, VS code settings, run custom code, forward ports and much more!
Let's add a devcontainer.json file and add a custom image.
.devcontainer/devcontainer.json
{
// Name this configuration
"name": "Codespace for Skills!",
// Use the base codespace image
"image": "mcr.microsoft.com/vscode/devcontainers/universal:latest",
"remoteUser": "codespace",
"overrideCommand": false
}
Click Commit changes and then select Commit changes directly to the main branch.
Create a new codespace by navigating back to the Code tab of your repository.
Click the green Code button located in the middle of the page.
Click the Codespaces tab on the box that pops up.
Click the Create codespace on main button OR click the + sign on the tab. This will create a new codespace on the main branch. (Notice your other codespace listed here.)
Wait about 2 minutes for the codespace to spin itself up.
Verify that your new codespace is is running, as you did previously.
Note the image being used is the default image provided for GitHub Codespaces. It includes runtimes and tools for Python, Node.js, Docker, and more. See the full list here: https://aka.ms/ghcs-default-image. Your development team can use any custom image that has the necessary prerequisites installed. For more information, see codespace image.
Nice work! 🎉 You created a codespace with a custom image!
You can customize your codespace by adding VS code extensions, adding features, setting host requirements, and much more.
Let's customize some settings in the .devcontainer.json file!
,
// Add the IDs of extensions you want installed when the container is created.
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot"
]
},
"codespaces": {
"openFiles": [
"codespace.md"
]
}
}
Click Commit changes and then select Commit changes directly to the main branch.
Create a new codespace by navigating to the landing page of your repository.
Click the Code button located in the middle of the page.
Click the Codespaces tab on the box that pops up.
Click the Create codespace on main button.
Wait about 2 minutes for the codespace to spin itself up.
Verify your codespace is running, as you did previously.
The codespace.md file should show up in the VS Code editor.
The copilot extension should show up in the VS Code extension list.
This will add a VS Code extension as well as open a file on start up of the codespace.
Next lets add some code to run upon creation of the codespace!
,
"postCreateCommand": "echo '# Writing code upon codespace creation!' >> codespace.md"
Click Commit changes and then select Commit changes directly to the main branch.
Create a new codespace by navigating to the landing page of your repository.
Click the Code button located in the middle of the page.
Click the Codespaces tab on the box that pops up.
Click the Create codespace on main button.
Wait about 2 minutes for the codespace to spin itself up.
Verify your codespace is running, as you did previously.
Verify the codespace.md file now has the text Writing code upon codespace creation!.
Wait about 20 seconds then refresh this page for the next step.
Nicely done customizing your codespace! 🥳
When using any development environment, customizing the settings and tools to your preferences and workflows is an important step. GitHub Codespaces offers two main ways of personalizing your codespace: Settings Sync with VS Code and dotfiles.
Dotfiles will be the focus of this activity.
What are dotfiles? Dotfiles are files and folders on Unix-like systems starting with . that control the configuration of applications and shells on your system. You can store and manage your dotfiles in a repository on GitHub.
Let's see how this works!
Start from the landing page of your repository.
Click the Code button located in the middle of the page.
Click the Codespaces tab on the box that pops up.
Click the Create codespace on main button.
Wait about 2 minutes for the codespace to spin itself up.
Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below:

From inside the codespace in the VS Code explorer window, create a new file setup.sh.
Add the following code inside of the file:
#!/bin/bash sudo apt-get update sudo apt-get install sl
Note: The file should autosave.
git add setup.sh --chmod=+x git commit -m "Adding setup.sh from the codespace!"
git push
Switch back to the homepage of your repository and view the setup.sh to verify the new code was pushed to your repository.
Close the codespace web browser tab.
Click the Create codespace on main button.
Wait about 2 minutes for the codespace to spin itself up.
Verify your codespace is running, as you did previously.
Verify the setup.sh file is present in your VS Code editor.
From the VS Code terminal, type or paste:
/usr/games/sl
Congratulations friend, you've completed this course!
Here's a recap of all the tasks you've accomplished in your repository:
Get help: Review the GitHub status page
© 2023 GitHub • Code of Conduct • MIT License
| Back | FazBrowse Home | New Git URL |