Skip to main content

Открытие существующего пространства кода

Вы можете повторно открыть пространство кода, закрытое или остановленное, и вернуться к работе.

Note

GitHub Codespaces is not available on subdomains of GHE.com, such as octocorp.ghe.com.

You can reopen any of your active or stopped codespaces on GitHub, in Visual Studio Code, or by using GitHub CLI. You can't reopen a codespace that has been deleted. See Understanding the codespace lifecycle.

You can view all your codespaces on the "Your codespaces" page at github.com/codespaces. From this page, you can:

Resuming a codespace from a repository page

You can quickly resume a codespace when you're viewing a repository on GitHub.

  1. With the Code tab of your repository displayed on GitHub, press , (the comma key).

    The "Resume codespace" page is displayed. This allows you to resume your most recently used codespace for the currently selected branch of the repository or, if you were viewing a pull request, for the topic branch of the pull request.

    Screenshot of the "Resume codespace" page showing the "Resume this codespace" and "Create a new one" buttons.

  2. Click Resume this codespace.

    Alternatively, if you want to create a new codespace for this branch of the repository, click Create a new one.

    Note

    If you don't have an existing codespace for this branch, the page is titled "Create codespace" and a button labeled Create a new codespace is displayed.

You can bookmark the address of this page if you want to get back to it quickly to resume your codespace. Alternatively you can use the address in a link to provide other people with a quick way of creating and resuming their own codespaces for this repository.

Opening an existing codespace from the "Your codespaces" page

  1. In the top-left corner of GitHub, select , then click Codespaces to take you to the "Your codespaces" page at github.com/codespaces.

  2. To open a codespace in your default editor, click the name of the codespace. You can set your default editor for Codespaces in your personal settings page. See Setting your default editor for GitHub Codespaces.

    To open the codespace in an editor other than your default:

    1. Click the ellipsis (...) to the right of the codespace you want to open.
    2. Click Open in.
    3. Click Open in APPLICATION.

    Screenshot of the "Open in" dialog, with "Open in Visual Studio Code" highlighted.

    You can open the codespace in:

    • Your browser
    • Visual Studio Code
    • JupyterLab

    If you choose Visual Studio Code, you must make sure you have installed the selected application on your local machine.

    If you choose JupyterLab, the JupyterLab application must be installed in the codespace. The default dev container image includes JupyterLab, so codespaces created from the default image will always have JupyterLab installed. For more information about the default image, see Introduction to dev containers and the devcontainers/images repository. If you're not using the default image in your dev container configuration, you can install JupyterLab by adding the ghcr.io/devcontainers/features/python feature to your devcontainer.json file. You should include the option "installJupyterlab": true. For more information, see the README for the python feature, in the devcontainers/features repository.

Linking to an existing codespace

You can create links to your existing codespaces. This is useful if you have a long-lived codespace that you return to frequently. You can save the link in a location of your choice, as an alternative to using the link on https://github.com/codespaces.

Note

You can only open your own codespaces. If someone clicks a link to one of your codespaces they will see a 404 error message.

Create a link using one of the following URL patterns. In these URLs CODESPACE-NAME represents the unique, permanent name of the codespace, such as literate-space-parakeet-w5vg5ww5p793g7g9, not the codespace's display name. You can find the name of a codespace by copying the link to the codespace on your https://github.com/codespaces page and extracting the codespace name from the URL.

Link opens inLink syntax
VS Code web clienthttps://CODESPACE-NAME.github.dev
VS Code web client with a specified workspacehttps://CODESPACE-NAME.github.dev?folder=/workspaces/PATH/TO/WORKSPACE/DIRECTORY
VS Code desktop applicationhttps://github.com/codespaces/CODESPACE-NAME?editor=vscode
JupyterLabhttps://github.com/codespaces/CODESPACE-NAME?editor=jupyter

Reopening an existing codespace

Note

To use GitHub Codespaces in VS Code, you need to install the Codespaces extension. See Using GitHub Codespaces in Visual Studio Code.

  1. In the VS Code desktop application, open the Command Palette with Command+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux).

  2. Type "Codespaces" and select one of the following commands.

    • To open a codespace in a new window of VS Code, select Codespaces: Open Codespace in New Window
    • To open a codespace in the web editor, select Codespaces: Open in Browser
  3. Click the codespace that you want to open.

    Screenshot of the VS Code Command Palette showing a list of codespaces available to connect to.

You can also access the commands listed above by navigating to the Remote Explorer view in VS Code and right-clicking the codespace that you want to open.

Screenshot of a codespace selected in the Remote Explorer, with "Open in Browser" highlighted in the right-click menu.

Note

If the Remote Explorer is not displayed in the Activity Bar:

  1. Access the Command Palette. For example, by pressing Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux).
  2. Type: details.
  3. Click Codespaces: Details.

Linking to an existing codespace

You can create links to your existing codespaces. This is useful if you have a long-lived codespace that you return to frequently. You can save the link in a location of your choice, as an alternative to using the link on https://github.com/codespaces.

Note

You can only open your own codespaces. If someone clicks a link to one of your codespaces they will see a 404 error message.

Create a link using one of the following URL patterns. In these URLs CODESPACE-NAME represents the unique, permanent name of the codespace, such as literate-space-parakeet-w5vg5ww5p793g7g9, not the codespace's display name. You can find the name of a codespace by copying the link to the codespace on your https://github.com/codespaces page and extracting the codespace name from the URL.

Link opens inLink syntax
VS Code web clienthttps://CODESPACE-NAME.github.dev
VS Code web client with a specified workspacehttps://CODESPACE-NAME.github.dev?folder=/workspaces/PATH/TO/WORKSPACE/DIRECTORY
VS Code desktop applicationhttps://github.com/codespaces/CODESPACE-NAME?editor=vscode
JupyterLabhttps://github.com/codespaces/CODESPACE-NAME?editor=jupyter

Reopening an existing codespace

If you have installed GitHub CLI, you can use it to work with GitHub Codespaces. For installation instructions for GitHub CLI, see the GitHub CLI repository.

  1. In a terminal, enter one of the following GitHub CLI commands.

    • To open a codespace in VS Code, enter:

      Shell
      gh codespace code
      

      Note

      You must have VS Code installed on your local machine. See Setting up Visual Studio Code in the VS Code documentation.

    • To open a codespace in the browser, enter:

      Shell
      gh codespace code --web
      
    • To open a codespace in JupyterLab, enter:

      Shell
      gh codespace jupyter
      

      Note

      The JupyterLab application must be installed in the codespace you are opening. The default dev container image includes JupyterLab, so codespaces created from the default image will always have JupyterLab installed. For more information about the default image, see Introduction to dev containers and the devcontainers/images repository. If you're not using the default image in your dev container configuration, you can install JupyterLab by adding the ghcr.io/devcontainers/features/python feature to your devcontainer.json file. You should include the option "installJupyterlab": true. For more information, see the README for the python feature, in the devcontainers/features repository.

    • To access a codespace from the command line, over SSH, enter:

      Shell
      gh codespace ssh
      
  2. Using the arrow keys, navigate to the codespace that you want to open.

  3. To open the codespace, press Enter.

See gh codespace code in the GitHub CLI manual.

Further reading