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 GitHub.com. 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."

Introduction

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, 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."

Prerequisites

  • 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 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. You must provide billing information in order to start a free trial. 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.

  1. In the upper-right corner of any page, click your profile photo, then click Settings.

    Settings icon in the user bar

  2. In the "Code, planning, and automation" section of the sidebar, click GitHub Copilot.

  3. On the GitHub Copilot settings page, click Enable GitHub Copilot.

    Screenshot of GitHub Copilot settings with Enable GitHub Copilot button emphasized

  4. Choose whether you want to pay monthly or yearly, and click Continue to get access to Copilot.

    • If your personal account meets the criteria for a free GitHub Copilot subscription instead of a trial, you will automatically be taken to step 6.

    Screenshot of trial setup with Continue to get access to Copilot button emphasized

  5. Follow the steps to confirm your payment details, then click Submit.

  6. Select your preferences, then click Save and get started.

    Screenshot of GitHub Copilot settings with Save and get started button

    You can change these preferences at a later time by returning to your GitHub Copilot settings. For more information, see "Configuring GitHub Copilot in Visual Studio Code."

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 provides suggestions for numerous languages and a wide variety of frameworks, but works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++. The following samples are in JavaScript, but other languages will work similarly.

  1. Open Visual Studio Code.

  2. In Visual Studio Code, create a new JavaScript (*.js) file.

  3. In the JavaScript file, type the following function header.

    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. To accept the suggestion, press 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