The Wayback Machine - https://web.archive.org./web/20201123162224/https://docs.github.com/cn/free-pro-team@latest/github/developing-online-with-codespaces/using-codespaces-in-visual-studio-code
我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

在 Visual Studio Code 中使用代码空间

您可以将 GitHub Codespaces 扩展连接到您在 GitHub 上的帐户,直接在 Visual Studio Code 代码空间中开发。

代码空间可用于使用 GitHub Free 或 GitHub Pro 的用户帐户。 更多信息请参阅“GitHub 的产品”。

本文内容

注:Codespaces 目前是有限公测版,可能会有变动。 在公测期间,GitHub 不对 Codespaces 的可用性做任何保证。 有关加入公测的更多信息,请参阅“关于 Codespaces”。

基本要求

要直接在 Visual Studio Code 中开发代码空间,必须登录到 GitHub Codespaces 扩展。 GitHub Codespaces 扩展需要 Visual Studio Code 2020 年 10 月 1 日版本 1.51 或更高版本。

  1. 使用

Visual Studio Marketplace 安装 GitHub Codespaces 扩展。 更多信息请参阅 Visual Studio Code 文档中的扩展 Marketplace。 1. 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。 Visual Studio Code 中的 Remote Explorer 图标 2. 使用“REMOTE EXPLORER(远程资源管理器)”下拉列表,然后单击 GitHub CodespacesCodespaces 标头 3. 单击 Sign in to view Codespaces...(登录以查看 Codespaces...)登录以查看 Codespaces 4. 要授权 Visual Studio Code 访问您在 GitHub 上的帐户,请单击 Allow(允许)。 5. 登录 GitHub 以审批扩展。

在 Visual Studio Code 中创建代码空间

将 GitHub 帐户连接到 Visual Studio 代码空间 扩展后,您可以在 Visual Studio Code 或 GitHub 上创建的代码空间中进行开发。

  1. 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。
    Visual Studio Code 中的 Remote Explorer 图标
  2. 单击 Add(添加)图标,然后单击 Create New Codespace(创建新代码空间)
    Codespaces 中的 Create new Codespace(创建新代码空间)选项
  3. 键入,然后单击要在其中开发仓库的名称。
    搜索仓库以创建新的 Codespaces
  4. 单击要在其中开发的分支。
    搜索分支以创建新的 Codespaces
  5. 单击要在其中开发的实例类型。
    新 Codespaces 的实例类型

在 Visual Studio Code 中打开代码空间

  1. 在 Visual Studio Code 中,从左侧边栏单击 Remote Explorer 图标。
    Visual Studio Code 中的 Remote Explorer 图标
  2. 在 Codespaces(代码空间)下,单击您要在其中开发的代码空间。
  3. 单击 Connect to Codespace(连接到代码空间)图标。
    Visual Studio Code 中的连接到代码空间图标

在 Visual Studio Code 中删除代码空间

  1. 在 Codespaces(代码空间)下,右键点击您要删除的代码空间。
  2. 在下拉菜单中,单击 Delete Codespace(删除代码空间)
    在 GitHub 中删除代码空间

此文档对您有帮助吗?

Privacy policy

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。