Quickly learn how to use GitHub Copilot.
You can use Copilot to get answers to coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see What is GitHub Copilot?.
If you have access to Copilot Workspace, Copilot can also help you when you are editing files in a pull request on the GitHub website by offering you code completion suggestions. For more information about Copilot Workspace, see Using Copilot to help you work on a pull request.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for GitHub. Click the tabs above for instructions on using Copilot in other environments.
Get started for free
If you don't already have access to GitHub Copilot, you can set up a free trial or subscription for Copilot Pro on your personal GitHub account.
Alternatively, you can set up Copilot Free which enables you to enjoy limited access to some of the features of Copilot, without needing to sign up for a subscription. See About GitHub Copilot Free.
For more information about the different plans for GitHub Copilot, see Subscription plans for GitHub Copilot.
On GitHub, navigate to a repository and open a file.
Click the Copilot icon () at the top right of the file view.
Type a question in the "Ask Copilot" box at the bottom of the chat panel and press Enter.
For example, you could enter:
Copilot responds to your request in the panel.
You can continue the conversation by asking a follow-up question. For example, you could type "tell me more" to get Copilot to expand on its last comment.
There are many more things you can do with GitHub Copilot Chat in GitHub. For example:
For more information, see Asking GitHub Copilot questions in GitHub.
GitHub Copilot provides coding suggestions as you type in your editor. You can also ask Copilot coding-related questions, such as how best to code something, how to fix a bug, or how someone else's code works. For full details of what Copilot can do, see What is GitHub Copilot?.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for Windows Terminal. Click the tabs above for instructions on using Copilot in other environments.
After you've installed Windows Terminal Canary, you can use Copilot in Terminal Chat to ask command line-related questions.
Open Settings from the dropdown menu.
Go to the Terminal Chat (Experimental) setting.
Under Service Providers, select GitHub Copilot and Authenticate via GitHub to sign in.
Note
If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot in Windows Terminal if your organization owner has disabled GitHub Copilot in the CLI. See Managing policies for Copilot in your organization.
Open Terminal Chat (Experimental) in the dropdown menu.
In the Terminal Chat chat window, type how do i list all markdown files in my directory then press Enter.
how do i list all markdown files in my directory
Copilot's answer is displayed below your question.
Click on an answer to insert it to the command line.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for Visual Studio Code. Click the tabs above for instructions on using Copilot in other environments.
After you've installed the GitHub Copilot extension, you can ask Copilot coding-related questions.
If you have access to GitHub Copilot via your organization, you won't be able to use GitHub Copilot Chat if your organization owner has disabled chat. See Managing policies for Copilot in your organization.
Open an existing code file.
Open the Chat view from the Activity Bar.
At the bottom of the chat view, in the chat input field, type: explain this file.
explain this file
Press Enter.
Copilot replies in the chat view.
In the editor, select one or more lines of code that are not commented.
In the chat input field, type: add comments to these lines.
add comments to these lines
If you like the comments that Copilot suggests, hover over the suggested code in the chat view and click the "Insert at Cursor" icon to replace the selected lines with the suggested code.
The following example uses JavaScript, however other languages will work similarly. 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++. GitHub Copilot can also assist in query generation for databases, generating suggestions for APIs and frameworks, and can help with infrastructure as code development.
Open Visual Studio Code.
In Visual Studio Code, create a new JavaScript (*.js) file.
In the JavaScript file, type the following function header.
function calculateDaysBetweenDates(begin, end) {
GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.
To accept the suggestion, press Tab.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for Visual Studio. Click the tabs above for instructions on using Copilot in other environments.
In the Visual Studio menu bar, click View, then click GitHub Copilot Chat.
In the Copilot Chat window, type what does this file do then press Enter.
what does this file do
Select a line of code in the editor.
In the Copilot Chat window, type explain this line then press Enter.
explain this line
Open Visual Studio.
In Visual Studio, create a new JavaScript (*.js) file.
Instructions for using Copilot differ depending on where you are using it. This version of the quickstart is for JetBrains IDEs. Click the tabs above for instructions on using Copilot in other environments.
After you've installed the GitHub Copilot plugin, you can ask Copilot coding-related questions.
Open the Copilot Chat window by clicking the Copilot Chat icon at the right side of the JetBrains IDE window.
In your JetBrains editor, create a new JavaScript (*.js) file.