Creating a codespace

You can create a codespace for a branch in a repository to develop online.

Los Codespaces están disponibles para los repositorios que pertenecen a las organizaciones que utilizan GitHub Team y Nube de GitHub Enterprise.

Codespaces está disponible para las organizaciones que utilicen GitHub Team o Nube de GitHub Enterprise. Para obtener más información, consulta la sección "Productos de GitHub".

About codespace creation

You can create a codespace on GitHub.com, in Visual Studio Code, or by using CLI de GitHub. Cada codespace que crees está únicamente disponible para ti. Nadie más puede trabajar en tu codespace.

Codespaces are associated with a specific branch of a repository and the repository cannot be empty. Puedes crear más de un codespace por repositorio o incluso por rama. Sin embargo, cada cuenta de usuario tiene un límite de 10 codespaces. Si has alcanzado el límite y quieres crear un codespace nuevo, primero debes borrar un codespace. For more information, see "Deleting a codespace."

When you create a codespace, a number of steps happen to create and connect you to your development environment:

  • Step 1: VM and storage are assigned to your codespace.
  • Step 2: Container is created and your repository is cloned.
  • Step 3: You can connect to the codespace.
  • Step 4: Codespace continues with post-creation setup.

For more information on what happens when you create a codespace, see "Deep Dive."

For more information on the lifecycle of a codespace, see "Codespaces lifecycle."

If you want to use Git hooks for your codespace, then you should set up hooks using the devcontainer.json lifecycle scripts, such as postCreateCommand, during step 4. Since your codespace container is created after the repository is cloned, any git template directory configured in the container image will not apply to your codespace. Hooks must instead be installed after the codespace is created. For more information on using postCreateCommand, see the devcontainer.json reference in the Visual Studio Code documentation.

Puedes editar código, depurar y utilizar comandos de git mientras que desarrollas en un codespace con Visual Studio Code. Para obtener más información, consulta la sección documentación de Visual Studio Code.

Puedes ver cualquier codespace disponible que hayas creado en github.com/codespaces.

Access to Codespaces

Los Codespaces están disponibles para los repositorios que pertenecen a las organizaciones que utilizan GitHub Team y Nube de GitHub Enterprise.

When you have access to Codespaces, you'll see a "Codespaces" tab within the Code drop-down menu when you view a repository.

You'll have access to codespaces under the following conditions:

  • You are a member of an organization that has enabled Codespaces and set a spending limit.
  • An organization owner has granted you access to Codespaces.
  • The repository is owned by the organization that has enabled Codespaces.

Note: Individuals who have already joined the beta with their personal GitHub account will not lose access to Codespaces, however Codespaces for individuals will continue to remain in beta.

Organization owners can allow all members of the organization to create codespaces, limit codespace creation to selected organization members, or disable codespace creation. For more information about managing access to codespaces within your organization, see "Enable Codespaces for users in your organization."

Before Codespaces can be used in an organization, an owner or billing manager must have set a spending limit. For more information, see "About spending limits for Codespaces."

If you would like to create a codespace for a repository owned by your personal account or another user, and you have permission to create repositories in an organization that has enabled Codespaces, you can fork user-owned repositories to that organization and then create a codespace for the fork.

Creating a codespace

  1. En GitHub.com, visita la página principal del repositorio.

  2. Under the repository name, use the "Branch" drop-down menu, and select the branch you want to create a codespace for.

    Branch drop-down menu

  3. Under the repository name, use the Code drop-down menu, and in the Codespaces tab, click New codespace.

    New codespace button

    If you are a member of an organization and are creating a codespace on a repository owned by that organization, you can select the option of a different machine type. From the dialog box, choose a machine type and then click Create codespace.

    Machine type choice

    Note: Your choice of available machine types may be limited by a policy configured for your organization, or by a minimum machine type specification for your repository. Para obtener más información, consulta las secciones "Restringir el acceso a los tipos de máquina" y "Configurar una especificación mínima para las máquinas de los codespaces".

After you connect your account on GitHub.com to the Acerca de GitHub Codespaces extension, you can create a new codespace.

  1. En Visual Studio Code, en la barra lateral izquierda, da clic en el icono de Explorador Remoto. El icono de explorador remoto en Visual Studio Code

  2. Da clic en el icono de Agregar y luego en Crear codespace nuevo.

    La opciòn de crear un codespace nuevo en Codespaces

  3. Teclea y luego da clic en el nombre del repositorio en el que quieras desarrollar.

    Buscar un repositorio para crear un Codespaces nuevo

  4. Da clic en la rama en la que quieras desarrollar.

    Buscar una rama para crear un Codespaces nuevo

  5. Haz clic en el tipo de máquina en la que quieres desarrollar.

    Tipos de instancia para un Codespaces nuevo

    Note: Your choice of available machine types may be limited by a policy configured for your organization, or by a minimum machine type specification for your repository. Para obtener más información, consulta las secciones "Restringir el acceso a los tipos de máquina" y "Configurar una especificación mínima para las máquinas de los codespaces".

Para aprender más sobre el CLI de GitHub, consulta la sección "Acerca del CLI de GitHub".

To create a new codespace, use the gh codespace create subcommand.

gh codespace create 

You are prompted to choose a repository, a branch, and a machine type (if more than one is available).

Alternatively, you can use flags to specify some or all of the options:

gh codespace create -r owner/repo -b branch -m machine-type 

Replace owner/repo with the repository identifier. Replace branch with the name of the branch, or the full SHA hash of the commit, that you want to be initially checked out in the codespace. If you use the -r flag without the b flag, the codespace is created from the default branch.

Replace machine-type with a valid identifier for an available machine type. Identifiers are strings such as: basicLinux32gb and standardLinux32gb. The type of machines that are available depends on the repository, your user account, and your location. If you enter an invalid or unavailable machine type, the available types are shown in the error message. If you omit this flag and more than one machine type is available you will be prompted to choose one from a list.

For more information about this command, see the CLI de GitHub manual.

¿Te ayudó este documento?

Política de privacidad

¡Ayúdanos a hacer geniales estos documentos!

Todos los documentos de GitHub son de código abierto. ¿Notas algo que esté mal o que no sea claro? Emite una solicitud de cambios.

Haz una contribución

O, aprende cómo contribuir.