Skip to main content

codespace を作成する

リポジトリのブランチの codespace を作成して、オンラインで開発できます。

Codespaces are available for repositories owned by organizations using GitHub Team and GitHub Enterprise Cloud.

Codespaces is available for organizations using GitHub Team or GitHub Enterprise Cloud. 詳しい情報については「GitHubの製品」を参照してください。

codespace の作成について

You can create a codespace on, in Visual Studio Code, or by using GitHub CLI. 各コードスペースは、作成者だけが利用できます。 他者のcodespaceで作業することはできません。

Codespaces はリポジトリの特定のブランチに関連付けられており、リポジトリを空にすることはできません。 リポジトリごと、さらにはブランチごとに1つ以上のcodespaceを作成できます。 However, each personal account has a limit of 10 codespaces. この制限に達した場合に新しいcodespaceを作成したいなら、まずcodespaceを削除しなければなりません。詳しい情報については、「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 VS Code documentation.

VS Codeでcodespace内で開発をする間に、コードを編集し、デバッグし、Gtiのコマンドを使うことができます。 詳しい情報についてはVS Codeのドキュメンテーションを参照してください。


To speed up codespace creation, repository administrators can enable Codespaces prebuilds for a repository. For more information, see "About Codespaces prebuilds."

Access to Codespaces

Codespaces are available for repositories owned by organizations using GitHub Team and GitHub Enterprise Cloud.

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.

codespace を作成する

  1. GitHub.comで、リポジトリのメインページにアクセスしてください。

  2. リポジトリ名の下で、[Branch] ドロップダウンメニューを使用して、codespace を作成するブランチを選択します。

    [Branch] ドロップダウンメニュー

  3. Click the Code button, then click the Codespaces tab.

    [New codespace] ボタン

  4. Create your codespace, either using the default options, or after configuring advanced options:

    • Use the default options

      To create a codespace using the default options, click Create codespace on BRANCH.

      Optionally, before clicking Create codespace on BRANCH, you can click the down arrow at the side of the button to see what machine type will be used for your codespace.

      View the default machine type

      Note: The machine type with the lowest resources that are valid for the repository is selected by default.

    • Configure options

      To configure advanced options for your codespace, such as a different machine type or a particular devcontainer.json file:

      1. Click the down arrow at the side of the Create codespace on BRANCH button, then click Configure and create codespace.

      2. Click the Configure and create codespace button.

      3. On the options page for your codespace, choose your preferred options from the drop-down menus.

        The codespace options page


      4. Click Start session.

After you connect your account on to the GitHub Codespaces extension, you can create a new codespace. For more information about the GitHub Codespaces extension, see the VS Code Marketplace marketplace.

Note: Currently, VS Code doesn't allow you to choose a dev container configuration when you create a codespace. If you want to choose a specific dev container configuration, use the GitHub web interface to create your codespace. For more information, click the Web browser tab at the top of this page.

  1. VS Codeの左サイドバーで、 Remote Explorerのアイコンをクリックしてください。 Visual Studio CodeのRemote Explorerアイコン

  2. Click the Add icon: .

    Codespaces の [Create New Codespace] オプション

  3. Type the name of the repository you want to develop in, then select it.

    新しい Codespaces を作成するためのリポジトリを検索する

  4. 開発するブランチをクリックします。

    新しい Codespaces を作成するためのブランチを検索する

  5. Click the machine type you want to use.

    新しい Codespaces のインスタンスタイプ

    注釈: 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. For more information, see "Restricting access to machine types" and "Setting a minimum specification for codespace machines."

To learn more about GitHub CLI, see "About GitHub CLI."

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).

Note: Currently, GitHub CLI doesn't allow you to choose a dev container configuration when you create a codespace. If you want to choose a specific dev container configuration, use the GitHub web interface to create your codespace. For more information, click the "Web browser" tab at the top of this page.

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 personal 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 GitHub CLI manual.