跳至主要内容

在 GitHub Codespaces 中使用 Visual Studio Code 命令面板

您可以使用 Visual Studio Code 的命令面板功能,在 GitHub Codespaces 中访问许多命令。

关于 Visual Studio Code 命令面板

VS Code 命令面板是 Visual Studio Code 的核心功能之一,可在 GitHub Codespaces 中使用。命令面板让您能够访问许多针对 GitHub Codespaces 和 VS Code 的命令。有关使用 VS Code 命令面板的更多信息,请参阅 VS Code 文档中的 用户界面

访问 VS Code 命令面板

您可以通过多种方式访问 VS Code 命令面板。

  • Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux).

    请注意,此快捷键在 Firefox 中是保留的。

  • F1

  • 在应用程序菜单中,点击 视图 > 命令面板

Codespaces 命令

要查看所有与 GitHub Codespaces 相关的命令,请访问 VS Code 命令面板,然后开始输入 “Codespaces”。

Screenshot of the Command Palette with "codespaces" entered. The dropdown lists all commands that relate to GitHub Codespaces.

挂起或停止代码空间

如果您添加了新的密钥或更改了机器类型,需要停止并重新启动代码空间才能使更改生效。

要挂起或停止代码空间的容器,请访问 VS Code 命令面板,然后开始输入 “stop”。选择 Codespaces: Stop Current Codespace

Screenshot of the Command Palette with the search text "stop" and the option "Codespaces: Stop Current Codespace."

添加预定义的开发容器配置

要添加预定义的开发容器配置,请访问 VS Code 命令面板,然后开始输入 “add dev”。点击 Codespaces: Add Dev Container Configuration Files

Screenshot of the Command Palette, with "add dev" entered and "Codespaces: Add Dev Container Configuration Files" listed.

重建代码空间

如果您添加了开发容器或编辑了任何配置文件(devcontainer.jsonDockerfile),则必须重建代码空间才能使更改生效。

要重建容器,请访问 VS Code 命令面板,然后开始输入 “rebuild”。选择 Codespaces: Rebuild Container

Screenshot of the Command Palette with the search text "rebuild" and the option "Codespaces: Rebuild Container."

提示

您可能偶尔需要执行完整重建,以清除缓存并使用全新镜像重建容器。有关更多信息,请参阅 在代码空间中重建容器

Codespaces 日志

您可以使用 VS Code 命令面板访问代码空间创建日志,或使用它导出所有日志。

要获取 GitHub Codespaces 的日志,请访问 VS Code 命令面板,然后开始输入 “export”。选择 Codespaces: Export Logs 导出所有与 GitHub Codespaces 相关的日志,或选择 Codespaces: View Creation Logs 查看与设置相关的日志。

Screenshot of the Command Palette with the search text "export" and the option "Codespaces: Export Logs."

延伸阅读

© . This site is unofficial and not affiliated with GitHub, Inc.