GitHub Codespaces is an instant, cloud-based development environment that uses a container to provide you with common languages, tools, and utilities for development. Codespaces is also configurable, allowing you to create a customized development environment that is the same for all users of your project. For more information, see "GitHub Codespaces overview."
Once Codespaces is enabled in an organization or enterprise, users can create a codespace from any branch or commit in an organization or enterprise repository and begin developing using cloud-based compute resources. You can connect to a codespace from the browser or locally using Visual Studio Code. 要开始使用 Codespaces，请参阅“Codespaces快速入门</0>”。 要了解有关 Codespaces 工作原理的更多信息，请参阅“深入了解代码空间”。
Setting Codespaces as the preferred editor for an assignment in GitHub Classroom assignments, is beneficial for both students and teachers. Codespaces is a good option for students using loaned devices or without access to a local IDE setup, since each codespace is cloud-based and requires no local setup. Students can launch a codespace for an assignment repository in Visual Studio Code directly in their browser, and begin developing right away without needing any further configuration.
For assignments with complex setup environments, teachers can customize the dev container configuration for a repository's codespaces. This ensures that when a student creates a codespace, it automatically opens with the development environment configured by the teacher. For more information on dev containers, see "Introduction to dev containers."
Note: Individual codespaces are automatically deleted if they are stopped and left unused for a prolonged period. For more information, see "Configuring automatic deletion of your codespaces."
The Codespaces Education benefit gives verified teachers a free monthly allowance of Codespaces hours to use in GitHub 课堂. The free allowance is estimated to be enough for a class of 50 with 5 assignments per month, on a 2 core machine with 1 codespace stored per student.
Note: The Codespaces Education benefit is currently in public beta and subject to change. During the beta release, your organization will not be charged if you exceed the free allowance.
To become a verified teacher, you need to be approved for an educator or teacher benefit. For more information, see "Applying for an educator or teacher benefit."
If you are eligible for the Codespaces Education benefit, when you enable Codespaces in GitHub 课堂 for your organization, GitHub automatically adds a Codespace policy to restrict machine types for all codespaces in the organization to 2 core machines. This helps you make the most of the free Codespaces usage. However, you can change or remove these policies in your organization settings. For more information, see "Restricting access to machine types."
When the Codespaces Education benefit moves out of beta, if your organization exceeds their free allowance for Codespaces usage, your organization will be billed for additional usage. For more information, see "About billing for Codespaces."
Codespaces is available to use with GitHub 课堂 for organizations that use GitHub Team. If you are eligible for the Codespaces Education benefit, you must enable Codespaces through GitHub 课堂, instead of enabling it directly in your organization settings. Otherwise, your organization will be billed directly for all usage of Codespaces.
登录 GitHub Classroom。
Click New classroom.
In the list of organizations, click the organization you'd like to use for your classroom. Organizations that are eligible for Codespaces will have a note showing that they are eligible. Optionally, you can create a new organization. For more information, see "Creating a new organization from scratch."
In the "Name your classroom" page, under "Codespaces in your Classroom", click Enable. Note that this will enable Codespaces for all repositories and users in the organization.
When you are ready to create the new classroom, click Create classroom.
登录 GitHub Classroom。
Under "GitHub Codespaces", click Enable. This will enable Codespaces for all repositories and users in the organization. A new Codespace policy is also added to restrict machine types for all codespaces in the organization to 2 core machines.
You can use the same methods as above to disable Codespaces for your organization as well. Note that this will disable Codespaces for all users and repositories in the organization.
To make Codespaces available to students for an assignment, you can choose Codespaces as the supported editor for the assignment. When creating a new assignment, in the "Add your starter code and choose your optional online IDE" page, under "Add a supported editor", select GitHub Codespaces from the dropdown menu.
If you use a template repository for an assignment, you can define a dev container in the repository to customize the tools and runtimes available to students when they launch a codespace to work on the assignment. If you do not define a dev container, GitHub Codespaces will use a default configuration, which contains many of the common tools that your students might need for development. For more information on defining a dev container, see "Add a dev container configuration to your repository."
When a student opens an assignment, the repository's README file includes their teacher's recommendation of the IDE they should use for the work.
Students can launch a new or existing codespace by clicking the Code button on the main page of the assignment repository, then selecting the Codespaces tab. For more information, see "Creating a codespace."
Teachers can view each student's codespace for an assignment in the assignment overview page. You can click on the Codespaces icon on the right side of each student row to launch the codespace.
When you connect to a codespace through a browser, auto-save is enabled automatically. If you want to save changes to the repository, you will need to commit the changes and push them to a remote branch. If you leave your codespace running without interaction for 30 minutes by default, the codespace will timeout and stop running. Your data will be preserved from the last time you made a change. For more information on the lifecycle of a codespace, see "Codespaces lifecycle."