Skip to main content

Quickstart for GitHub Copilot

GitHub Copilot can help you work, by offering inline suggestions as you code.

GitHub Copilot is available to GitHub customers with a personal account on and GitHub Enterprise Cloud organizations owned by an enterprise account.

GitHub Copilot is free to use for verified students, teachers, and maintainers of popular open source projects. If you are not a student, teacher, or maintainer of a popular open source project, you can try GitHub Copilot for free with a one-time 60-day trial. After the free trial, you will need a paid subscription for continued use. For more information, see "About billing for GitHub Copilot."


GitHub Copilot is an AI pair programmer. You can use GitHub Copilot to get suggestions for whole lines or entire functions right inside your editor.

This guide will show you how to sign up for GitHub Copilot through your personal account, install the GitHub Copilot extension in Visual Studio Code, and get your first suggestion. For more information on GitHub Copilot, see "About GitHub Copilot." For more in-depth information on how to use GitHub Copilot in a variety of environments, see "Getting Started."


  • GitHub Copilot is free to use for verified students, teachers, and open source maintainers.
  • If you are not a student, teacher, or open source maintainer, you will need an active trial or subscription. For more information, see "About billing for GitHub Copilot."
  • To use GitHub Copilot in Visual Studio Code, you must have Visual Studio Code installed. For more information, see the Visual Studio Code documentation.

Signing up for GitHub Copilot

Before you can start using GitHub Copilot, you will need to set up a free trial or subscription for your personal account.

Note: If you are a member of an organization owned by a GitHub Enterprise Cloud account with a GitHub Copilot subscription, and you have been assigned a GitHub Copilot seat by your organization, you can proceed to "Installing the GitHub Copilot extension for Visual Studio Code."

在开始使用 GitHub Copilot 之前,需要设置免费试用或订阅。

  1. 在任何页面的右上角,单击个人资料照片,然后单击“设置”。

    用户栏中的 Settings 图标

  2. 在边栏的“代码、规划和自动化”部分,单击“ GitHub Copilot”。

  3. 在 GitHub Copilot 设置页面上,单击“启用 GitHub Copilot”。

    GitHub Copilot 设置屏幕截图,其中突出显示了启用 GitHub Copilot 按钮

  4. 选择要按月还是按年付款,然后单击“继续访问 Copilot”。

    • 如果个人帐户符合免费 GitHub Copilot 订阅(而不是试用)的条件,将自动转到步骤 6。

    试用设置的屏幕截图,其中突出显示了“继续访问 Copilot”按钮

  5. 按照步骤确认付款详细信息,然后单击“提交”。

  6. 选择首选项,然后单击“保存并开始”。

    带有“保存并开始”按钮的 GitHub Copilot 设置屏幕截图

    可以稍后通过返回到 GitHub Copilot 设置来更改这些首选项。 有关详细信息,请参阅“在 Visual Studio Code 中配置 GitHub Copilot”。

Installing the GitHub Copilot extension for Visual Studio Code

To use GitHub Copilot, you must first install the Visual Studio Code extension.

  1. In the Visual Studio Code Marketplace, go to the GitHub Copilot extension page and click Install. Install GitHub Copilot extension Visual Studio Code
  2. A popup will appear, asking to open Visual Studio Code. Click Open Visual Studio Code.
  3. In the "Extension: GitHub Copilot" tab in Visual Studio Code, click Install. Install button in Visual Studio Code
  4. If you have not previously authorized Visual Studio Code in your GitHub account, you will be prompted to sign in to GitHub in Visual Studio Code.
    • If you have previously authorized Visual Studio Code in your GitHub account, GitHub Copilot will be automatically authorized. Screen shot of Visual Studio Code authorization screen
  5. In your browser, GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize Visual Studio Code.
  6. In Visual Studio Code, in the "Visual Studio Code" dialogue box, to confirm the authentication, click Open.

Getting your first suggestion

Note: If you have duplication detection enabled for GitHub Copilot, you may receive limited suggestions, or no suggestions, when using the code examples provided. As an alternative, you can start by typing your own code to see suggestions from GitHub Copilot. For more information on duplication detection, see "Enabling or disabling duplication detection."

GitHub Copilot 为多种语言和各种框架提供建议,但尤其适用于 Python、JavaScript、TypeScript、Ruby、Go、C# 和 C++。 The following samples are in JavaScript, but other languages will work similarly.

  1. Open Visual Studio Code.

  2. 在 Visual Studio Code 中,创建一个新的 JavaScript (*.js) 文件。

  3. 在 JavaScript 文件中,键入以下函数标头。

    function calculateDaysBetweenDates(begin, end) {

    GitHub Copilot will automatically suggest an entire function body in grayed text, as shown below. The exact suggestion may vary. First suggestion Visual Studio Code

  4. 要接受建议,请按 Tab

Next Steps

You successfully installed GitHub Copilot and received your first suggestion, but that's just the beginning! Here are some helpful resources for taking your next steps with GitHub Copilot.

  • Getting Started: You've learned how to get your first suggestion in Visual Studio Code. These guides show you how to set up and navigate the various functions of GitHub Copilot across all of the supported environments.
  • GitHub Copilot: See practical examples of how GitHub Copilot can help you work.
  • Configuring GitHub Copilot: These guides provide details on how to configure GitHub Copilot to your personal preferences.

Further reading