安装、升级与预发布版本
选择 npm、WinGet、Homebrew、安装脚本或独立可执行文件,并管理更新渠道。
This page has not been translated into English yet. The original Chinese version is shown below.
通过 GitHub 使用 Copilot CLI 需要有效的 Copilot 订阅;组织或企业提供的访问权限还受管理员的 CLI 策略限制。Windows 需要 PowerShell 6 或更高版本。使用自己提供的模型 API Key 时,GitHub 认证规则另见认证与配置。
选择安装方式
| 环境 | 安装命令 | 前提 |
|---|---|---|
| 跨平台 npm | npm install -g @github/copilot | Node.js 22+ |
| Windows WinGet | winget install GitHub.Copilot | PowerShell 6+ |
| macOS / Linux Homebrew | brew install --cask copilot-cli | 已安装 Homebrew |
若 ~/.npmrc 设置了 ignore-scripts=true,安装时需要允许包的安装脚本:
npm_config_ignore_scripts=false npm install -g @github/copilot也可以从官方 copilot-cli Releases 下载适合平台的可执行文件,解压后运行。不要把 npm 所需的 Node.js 版本当作所有分发方式共同的安装步骤。
安装脚本
macOS 和 Linux 可以运行官方脚本:
curl -fsSL https://gh.io/copilot-install | bash没有 curl 时,官方也提供 wget -qO- https://gh.io/copilot-install | bash。以 root 运行可将管道结尾换为 | sudo bash,安装到 /usr/local/bin。
脚本支持两个环境变量:PREFIX 指定安装前缀,root 默认 /usr/local,普通用户默认 $HOME/.local;VERSION 指定版本,默认最新版本。固定版本时使用 Releases 中存在的版本号,不能把官网示例中的历史版本当作当前最新版。
预发布渠道
需要验证尚未进入稳定版的功能时,按安装方式选择对应渠道:
npm install -g @github/copilot@prerelease
brew install --cask copilot-cli@prereleasewinget install GitHub.Copilot.Prerelease这些是替代安装选项,无需全部执行。预发布功能的实际可用性以当前版本、账号和管理策略为准。
检查与更新
copilot version 显示版本并检查更新;copilot update 下载和安装最新版本。交互会话中的 /version 和 /update 分别提供对应入口,/upgrade 是更新命令的别名。