注:Codespaces 目前是有限公测版,可能会有变动。 在公测期间,GitHub 不对 Codespaces 的可用性做任何保证。 有关加入公测的更多信息,请参阅“关于 Codespaces”。
基本要求
要直接在 Visual Studio Code 中开发代码空间,必须登录到 GitHub Codespaces 扩展。 GitHub Codespaces 扩展需要 Visual Studio Code 2020 年 10 月 1 日版本 1.51 或更高版本。
- 使用
Visual Studio Marketplace 安装 GitHub Codespaces 扩展。 更多信息请参阅 Visual Studio Code 文档中的扩展 Marketplace。
1. 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。
2. 使用“REMOTE EXPLORER(远程资源管理器)”下拉列表,然后单击 GitHub Codespaces。
3. 单击 Sign in to view Codespaces...(登录以查看 Codespaces...)。
4. 要授权 Visual Studio Code 访问您在 GitHub 上的帐户,请单击 Allow(允许)。
5. 登录 GitHub 以审批扩展。
在 Visual Studio Code 中创建代码空间
将 GitHub 帐户连接到 Visual Studio 代码空间 扩展后,您可以在 Visual Studio Code 或 GitHub 上创建的代码空间中进行开发。
- 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。
- 单击 Add(添加)图标,然后单击 Create New Codespace(创建新代码空间)。
- 键入,然后单击要在其中开发仓库的名称。
- 单击要在其中开发的分支。
- 单击要在其中开发的实例类型。
在 Visual Studio Code 中打开代码空间
- 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。
- 在 Codespaces(代码空间)下,单击您要在其中开发的代码空间。
- 单击 Connect to Codespace(连接到代码空间)图标。
在 Visual Studio Code 中删除代码空间
- 在 Codespaces(代码空间)下,右键点击您要删除的代码空间。
- 在下拉菜单中,单击 Delete Codespace(删除代码空间)。