# GitHub Copilot 怎么用：设置好 VS Code，从 agent 模式开始

> GitHub Copilot 是 GitHub 的 AI 编程助手。你写代码时它帮着补全，能回答关于项目的问题，在 agent 模式下还会规划任务、修改文件、运行命令，每个操作都由你批准。它可以用在 VS Code、JetBrains、Visual Studio 和 GitHub.com 上。用 GitHub 账号登录，在 VS Code 里打开一个文件夹，新开一个聊天就能开始。

Mindket 编辑部 · 发布于 2026-11-06 · 更新于 2026-11-06 · https://mindket.com/cn/learn/tools/github-copilot

## 要点

- GitHub Copilot 是 GitHub 的 AI 助手，内置在编辑器、GitHub.com 和终端里。
- 在编辑器里，agent 模式跨文件修改，每个操作由你批准。在 GitHub 上，云端智能体接过一个 issue，交回一个拉取请求。
- Copilot Free 不花钱，云端智能体则属于付费套餐。
- 待审的修改排成一个列表，你逐处保留或撤销，终端造成的改动只在 Source Control 里看得到。

## GitHub Copilot 是什么

GitHub Copilot 是 GitHub 推出的 AI 助手，GitHub 是微软旗下的代码托管网站。它帮你写、读、交付软件：你写代码时给出建议，回答关于代码库的问题，审查改动，也能接手你交给它的任务。GitHub 在 2021 年 6 月 29 日宣布了它，如今已经从自动补全发展到了智能体。

它可以在好几个地方用。VS Code、Visual Studio、JetBrains 系列、Neovim 和 Eclipse 以扩展或插件的方式加载它。在 GitHub.com 和 GitHub Mobile 应用里不用安装。另外还有命令行版和桌面应用，每个套餐都包含这两样。Copilot Free 不花钱，功能有限，付费套餐则增加模型、智能体，每月的 AI 额度也更多。

## GitHub Copilot 擅长做什么

- **边写边给代码建议**：能根据一句注释和周围的代码补完一行，甚至整个函数。Copilot Free 每月最多 2,000 次行内建议。
- **回答关于代码的问题**：在 Chat 里问某个文件是做什么的，或者测试为什么失败。编辑器、GitHub.com、GitHub Mobile 和 Windows Terminal 里都能问。
- **agent 模式下跨文件做和改**：描述一个小应用或一处修复，智能体会规划任务、修改文件、运行命令并检查结果，每一步由你批准。
- **把 issue 变成拉取请求**：把一个 GitHub issue 指派给 Copilot，它的云端智能体在后台工作，做完请你审查拉取请求。这需要付费套餐。
- **审查拉取请求**：Copilot 能为拉取请求写摘要，并提出改进建议。
- **自己选模型**：付费套餐可以为一次聊天挑选模型，Copilot Free 和 Copilot Student 则由系统自动替你选。

## 什么时候用 GitHub Copilot，什么时候换别的工具

GitHub Copilot 适合已经在编辑器里或 GitHub 上工作的人。右边一列里的工具都有自己的页面：[Cursor](https://mindket.com/cn/learn/tools/cursor) 是围绕智能体设计的编辑器，[Claude Code](https://mindket.com/cn/learn/tools/claude-code) 在终端窗口里工作，[Ollama](https://mindket.com/cn/learn/tools/ollama) 和 [LM Studio](https://mindket.com/cn/learn/tools/lm-studio) 把模型放在你自己的电脑上运行。

| 你要做的事 | 用 Copilot 吗 | 或者试试 |
| --- | --- | --- |
| 在 VS Code 或 JetBrains 里边写边补全行和函数 | 用，它就是从这里起步的 | Cursor，用它的 Tab 补全 |
| 一个请求改好几个文件，每个操作都由你批准 | 用，选 agent 模式 | Cursor 或 Claude Code |
| 把 GitHub 的 issue 交给智能体，换回一个拉取请求 | 用，需要付费套餐 | 留在 Copilot，它就长在 GitHub 里面 |
| 在终端窗口里工作 | 用，装 Copilot CLI | Claude Code |
| 在自己的电脑上离线运行模型 | 默认不行，它的模型在云端运行 | Ollama 或 LM Studio |
| 聊跟代码无关的事 | 不用，它为软件工作设计 | ChatGPT、Claude 或 Gemini |

## GitHub Copilot 怎么用，一步一步来

这条路线从 VS Code 开始，到你保留或撤销了修改为止。菜单名称用的是 VS Code 和 GitHub 文档里的写法。

1. **注册 GitHub 账号。**没有的话，到 [github.com](https://github.com) 注册。符合条件、还没有 Copilot 套餐的账号，登录 Copilot 时会自动加入 Copilot Free。
2. **安装 VS Code。**从 [code.visualstudio.com](https://code.visualstudio.com/download) 下载并安装。
3. **登录 Copilot。**把鼠标移到底部状态栏的 Copilot 图标上，选择 **Use AI Features**，挑一种登录方式，按提示完成。
4. **打开文件夹。**新建一个空文件夹，选择 **File** > **Open Folder**，把它打开。VS Code 问你是否信任这个文件夹时，在通知里选 **Manage**，再选 **Trust**。
5. **开始聊天。**打开 Chat 视图，点 **+** 新建一个聊天。
6. **选 Agent 和手动批准。**把 **Agent** 设为 **Agent**，这样它能改文件、运行命令，把 **Permissions** 设为 **Manual permissions**，这样它动手前会先问你。另外两种模式是 Ask 和 Plan。
7. **提出要求。**用平常的话描述你要的应用，按 Enter。聊天里出现批准提示时，先读它要做什么，再接受。
8. **逐处保留或撤销。**从聊天框上方的待审改动列表里打开一个文件，在每处改动旁选 **Keep** 或 **Undo**。在某个请求上点 **Restore Checkpoint**，整个请求都会回滚。

1. 登录 Copilot。把鼠标移到底部状态栏的 Copilot 图标上，选择 **Use AI Features**（使用 AI 功能）。
   ![示意图：VS Code 状态栏 Copilot 图标上方的 Use AI Features 按钮被金色圆框圈出。](https://mindket.com/blog/screens/github-copilot-1-use-ai-features.webp?v=8c525b52311f)
2. 打开 Chat 视图，点顶部的 **+** 新建一个聊天。
   ![示意图：VS Code 的 Chat 视图，标题栏右上角的加号按钮被金色圆框圈出。](https://mindket.com/blog/screens/github-copilot-2-new-chat.webp?v=9e86edbe729e)
3. 把模式设为 **Agent**，权限设为 **Manual permissions**（手动批准），这样 Copilot 能改文件，但动手前会先问你。然后写下你的请求。
   ![示意图：VS Code 聊天输入框里的 Agent 和 Manual permissions 两个下拉菜单被金色圆框圈出。](https://mindket.com/blog/screens/github-copilot-3-agent-permissions.webp?v=3726fa61f781)
4. 逐处读 Copilot 提出的改动。点 **Keep**（保留）接受，点 **Undo**（撤销）丢掉。
   ![示意图：聊天框上方待审改动行里的 Keep 和 Undo 按钮被金色圆框圈出。](https://mindket.com/blog/screens/github-copilot-4-keep-undo.webp?v=399168153e98)

*以下是 AI 绘制的 GitHub Copilot 在 VS Code 里的界面示意图，绘于 2026 年 11 月 6 日，按这些步骤画成。它们不是截图，实际界面可能不同，请以你看到的为准。*

> 菜单和桌面应用常有变化，某个按钮的位置可能和这些步骤说的不一样。本页顶部的教程视频会把每一步演示给你看。

## 一个可以直接试的例子

把下面这段提示词粘进第 7 步的聊天里，这是 VS Code 快速入门自己用的例子。它要一个能在浏览器里试用的小应用。

````text
Create a task list web app in a single index.html file with embedded CSS and JavaScript. Let me add, complete, and delete tasks. Save the tasks in local storage so they persist after a page reload. Use no external libraries.
````

- 智能体会创建一个 index.html 文件，凡是你的设置没有预先允许的操作，它做之前都会问你。
- 在浏览器里打开这个文件，应该能添加任务、标记完成、删除任务。
- 刷新页面，任务应该还在，因为提示词要求了本地存储。
- 哪一步失败了，就在聊天里描述你看到的，请智能体修好再测一遍。你自己把应用走一遍，才算数。

## 想要更好的结果

- 从 Manual permissions 开始，只在你熟悉的项目里放宽。Allow all 和 Autopilot 会跳过文件修改、终端命令和外部工具调用的确认。
- 凡是用过终端的运行，之后都去看一眼 Source Control 视图。待审改动列表只显示通过智能体自带编辑工具做的修改。
- 把整件事和限制都写进 issue，再指派给云端智能体。它读的是 issue 和已有的评论，之后新加的评论它看不到。
- 想不装任何东西试试 Copilot，就打开 [GitHub.com 上的 Copilot 首页](https://github.com/copilot)，在会话范围选择器里选一个仓库，问它该从哪里开始读。
- 从状态栏打开 Copilot 状态面板，看这个月用掉了多少。一次智能体请求可能消耗好几份。

## 套餐，用大白话说

Copilot Free 面向个人，功能有限，模型只有自动选择，每月有一份 AI 额度。Copilot Student 对经过验证的学生免费，经过验证的教师和热门开源项目的维护者，也可能免费获得 Copilot Pro。

Pro、Pro+ 和 Max 是付费的个人套餐，每月的 AI 额度依次更大。Business 和 Enterprise 面向组织，由管理员分配席位、设定策略。每个套餐现在多少钱，以 [GitHub 的套餐页面](https://docs.github.com/en/copilot/get-started/plans)为准。云端智能体属于付费套餐，Copilot Free 用不了。

## YouTube 教程

- [How to use GitHub Copilot (the complete beginner's guide)](https://www.youtube.com/watch?v=SJqGYwRq0uc) (GitHub)
- [How To Use GitHub Copilot in 2026: VS Code + the New Desktop App (Complete Guide)](https://www.youtube.com/watch?v=5Lg_bG907k8) (Powercademy)
- [Getting started with GitHub Copilot | Tutorial](https://www.youtube.com/watch?v=n0NlxUyA7FI) (GitHub)
- [Using Tools with Agents in VS Code](https://www.youtube.com/watch?v=wZrQ0TAfpFg) (Visual Studio Code)

## 深入学习 GitHub Copilot

- [GitHub Copilot agent 模式：在 VS Code 里做，再交给云端](https://mindket.com/cn/learn/vibe-coding/github-copilot-agent-mode)
- [Vibe coding 是什么？描述、运行、检查](https://mindket.com/cn/learn/vibe-coding/what-is-vibe-coding)

## 常见问题

### GitHub Copilot 免费吗？

部分免费。Free 套餐不收费，功能有限，每月带一些 AI 额度。经过验证的学生可以免费用 Copilot Student，付费套餐则增加模型和额度。

### GitHub Copilot 只能在 VS Code 里用吗？

不是。除了 VS Code，它在 Visual Studio 和 JetBrains 的编辑器里也能用，还能在终端、桌面应用，以及 GitHub.com 和 GitHub Mobile 上运行。上面的步骤用 VS Code，是因为它最容易上手。

### agent 模式和 Copilot 云端智能体有什么区别？

区别在运行的地方。agent 模式在你电脑上的编辑器里工作，你边看边批准。云端智能体在 GitHub 上后台工作，做完交回一个拉取请求，等你之后审查。

### GitHub Copilot 用的是哪些 AI 模型？

好几种。它 2021 年从 OpenAI Codex 起步，2024 年加入了模型选择，现在提供 OpenAI、Anthropic、xAI 和 Google 的模型。

### 该用 GitHub Copilot 还是 Cursor？

取决于你愿不愿意换编辑器。Copilot 装进 VS Code 或 JetBrains 里，Cursor 则是一个独立的应用。两者都能让智能体改文件、运行命令。

### Copilot 会不问我就改文件吗？

默认设置下不会。Manual permissions 会在任何没有被批准设置覆盖的操作之前先问你。更宽松的两档会跳过确认，所以只留给你信任的工作区。

## 资料来源

- [GitHub Docs: About GitHub Copilot](https://docs.github.com/en/copilot/get-started/what-is-github-copilot) (2026-11-06 查阅)
- [GitHub Docs: Plans for GitHub Copilot](https://docs.github.com/en/copilot/get-started/plans) (2026-11-06 查阅)
- [GitHub Docs: Quickstart for using GitHub Copilot on GitHub.com](https://docs.github.com/en/copilot/get-started/quickstart) (2026-11-06 查阅)
- [GitHub Docs: GitHub Copilot surfaces](https://docs.github.com/en/copilot/concepts/copilot-surfaces) (2026-11-06 查阅)
- [Wikipedia: GitHub Copilot](https://en.wikipedia.org/wiki/GitHub_Copilot) (2026-11-06 查阅)
- [VS Code docs: Set up GitHub Copilot in VS Code](https://code.visualstudio.com/docs/setup/copilot) (2026-11-05 查阅)
- [VS Code docs: Quickstart, complete your first task with an agent](https://code.visualstudio.com/docs/agents/quickstart) (2026-11-05 查阅)
- [VS Code docs: Review and revert agent changes](https://code.visualstudio.com/docs/agents/run/review-code-edits) (2026-11-05 查阅)
- [VS Code docs: Manage approvals and permissions](https://code.visualstudio.com/docs/agents/run/approvals) (2026-11-05 查阅)
- [GitHub Docs: Using Copilot in the cloud on GitHub](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/cloud-agent/use-cloud-agent-on-github) (2026-11-05 查阅)
- [GitHub on YouTube: How to use GitHub Copilot (the complete beginner's guide)](https://www.youtube.com/watch?v=SJqGYwRq0uc) (2026-11-06 查阅)
- [Powercademy on YouTube: How To Use GitHub Copilot in 2026](https://www.youtube.com/watch?v=5Lg_bG907k8) (2026-11-06 查阅)

[开始这一课](https://mindket.com/cn/learn/vibe-coding/github-copilot-agent-mode)
