Skip to main content

Setting up GitHub Copilot in the CLI

Learn how to enable and install GitHub Copilot in the CLI.

If you have a GitHub Copilot Individual subscription, you can install the GitHub Copilot in the CLI extension without needing to enable it for your organization.

If you are part of an organization with a GitHub Copilot Business subscription, the organization owner will need to enable Copilot in the CLI in the Copilot settings. You can then install the GitHub Copilot in the CLI extension.

Enabling or disabling Copilot in the CLI at the organization level

An organization owner can enable or disable Copilot in the CLI for the organization.

  1. 在 GitHub.com 的右上角,选择个人资料照片,然后单击 “你的组织”****。

    @octocat 的个人资料图片下的下拉菜单的屏幕截图。 “你的组织”以深橙色标出。

  2. 在组织旁边,单击“设置”。

  3. 在边栏的“代码、规划和自动化”部分中,按下“ Copilot”,然后按下“策略”。********

  4. To the right of "Copilot in the CLI", select the dropdown menu, then click Enabled or Disabled.

Installing Copilot in the CLI

To install Copilot in the CLI, you must have GitHub CLI installed. 有关 GitHub CLI 的安装说明,请参阅 GitHub CLI 存储库

  1. If you are have not already authenticated with your GitHub account, run the following command in your terminal.

    Shell
    gh auth login
    
  2. To install the Copilot in the CLI extension, run the following command.

    Shell
    gh extension install github/gh-copilot
    
  3. To update Copilot in the CLI, run the following command.

    Shell
    gh extension upgrade gh-copilot
    

To use gh to work with GitHub Copilot, type gh copilot SUBCOMMAND, for example, gh copilot explain.

Next steps

You successfully installed Copilot in the CLI. To learn more about how to use it, see "使用 GitHub Copilot(CLI 版)." If you want to configure usage analytics and the default behavior for the execute command option, see "在 CLI 中配置 GitHub Copilot."