GitHub Copilot CLI 命令速查表 - gh copilot 全参数
GitHub Copilot 命令行(gh copilot)命令都在这里了,从解释命令到生成建议、从别名到配置,按场景分类整理,复制即用。
解释命令 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日,内容持续校对官方文档。