You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS Code中批量添加提交作为Copilot Chat的上下文?

在VS Code中批量为GitHub Copilot Chat添加提交上下文

直接生成合并Diff作为上下文(推荐)

若你的核心需求是让Copilot评审当前分支相对于默认分支的所有变更,无需逐个添加提交:

  1. 打开VS Code终端,执行Git命令生成合并Diff(默认分支为main时):
    git diff main..HEAD
    
    若默认分支是master,替换为git diff master..HEAD
  2. 复制终端输出的全部Diff内容,粘贴到Copilot Chat输入框,再发送指令:
    please review the combined diff of all these changes as if it were a pull request
    

借助扩展实现批量添加提交

原生VS Code的Git Graph暂不支持批量添加提交到Chat上下文,可通过第三方扩展简化操作:

  • 安装Git Graph增强扩展
  • 打开Git Graph视图,按住Ctrl(Windows/Linux)或Cmd(Mac)选中当前分支相对于默认分支的所有提交
  • 右键选中的提交组,选择Add to Copilot Chat(部分版本扩展支持此批量操作)

优化Agent模式的操作流程

若仍想使用Agent模式,可配置自动批准Git命令以减少手动操作:

  1. 打开VS Code设置(快捷键Ctrl+,或Cmd+,)
  2. 搜索GitHub Copilot: Agent Auto Approve
  3. 将选项设置为all,Copilot执行Git命令时将自动获得批准

内容的提问来源于stack exchange,提问作者sparrowt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 07:12:39