GitHub Copilot CLI 命令速查表 - gh copilot 全参数

GitHub Copilot 命令行(gh copilot)命令都在这里了,从解释命令到生成建议、从别名到配置,按场景分类整理,复制即用。

AI 命令行·共 25 条命令·最后更新 2026-08-21

解释命令 5

gh copilot explain "git rebase -i HEAD~3"
用自然语言解释命令作用
gh copilot explain "kubectl get pods"
解释 k8s 等复杂命令
gh copilot explain "awk ..."
解释 awk/sed 脚本
gh copilot explain "docker compose up -d"
解释容器编排命令
gh copilot explain ":(){:|:&};:"
解释危险/晦涩命令(先懂再跑)

生成建议 5

gh copilot suggest -t shell "备份 mysql 到 s3"
生成 shell 命令(-t shell)
gh copilot suggest -t gh "列出我的 PR"
生成 gh 命令(-t gh)
gh copilot suggest -t git "撤销上次提交但保留改动"
生成 git 命令(-t git)
gh copilot suggest "监控端口 8080"
默认按上下文猜类型
gh copilot suggest -t shell "批量重命名文件"
复杂批处理命令生成

别名与配置 5

gh copilot alias
生成 shell 别名配置片段
gh copilot alias --help
查看别名子命令帮助
gh copilot config
查看/修改 Copilot CLI 配置
gh copilot config set <k> <v>
设置某项配置
gh extension list | grep copilot
确认 copilot 扩展已安装

集成与调试 5

@copilot
在 GitHub 议题/PR 中提及 Copilot
gh copilot suggest --help
查看 suggest 全部选项
gh auth status
确认 gh 已登录(Copilot 前置)
gh extension install github/gh-copilot
安装 copilot 扩展(如缺失)
gh copilot explain "$(history 1)"
解释刚敲的命令

实用技巧 5

建议生成后用 explain 复核
先 suggest 再 explain 双重确认
-t 明确类型
shell/gh/git 显式指定更准
配别名省打字
gh copilot alias 生成后 source 进 shell
危险命令先 explain
不懂的晦涩命令先解释再执行
结合 gh 工作流
与 gh pr/issue 串联做自动化

提示

  • GitHub Copilot CLI 是开发者基数最大的 AI 入口(gh 生态默认),但形态偏"解释/建议"而非自主 Agent,与 Claude Code 类互补。
  • suggest 后务必 explain 复核生成的命令,尤其 `-t shell` 涉及删改/网络的操作,先懂再跑。
  • 用 `gh copilot alias` 生成别名并进 shell,日常调用从 `gh copilot suggest` 缩成短命令。
  • 前置条件:`gh auth login` 已登录且 Copilot 订阅有效;扩展缺失用 `gh extension install github/gh-copilot`。

官方参考来源

命令整理自以下官方文档,点击核对最新用法。

由 巧匠 维护

公开更新于 2026年8月21日,内容持续校对官方文档。

联系我们

命令或描述有误?提交反馈、商务合作或产品建议都可发送邮件给我们。

联系我们