如何在VS Code中批量添加提交作为Copilot Chat的上下文?
在VS Code中批量为GitHub Copilot Chat添加提交上下文
直接生成合并Diff作为上下文(推荐)
若你的核心需求是让Copilot评审当前分支相对于默认分支的所有变更,无需逐个添加提交:
- 打开VS Code终端,执行Git命令生成合并Diff(默认分支为
main时):
若默认分支是git diff main..HEADmaster,替换为git diff master..HEAD - 复制终端输出的全部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命令以减少手动操作:
- 打开VS Code设置(快捷键
Ctrl+,或Cmd+,) - 搜索
GitHub Copilot: Agent Auto Approve - 将选项设置为
all,Copilot执行Git命令时将自动获得批准
内容的提问来源于stack exchange,提问作者sparrowt
相关产品推荐
相关产品推荐

