Skip to main content

Quickstart for GitHub Copilot

Quickly learn how to use GitHub Copilot.

Introduction

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?.

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.

S’inscrire à GitHub Copilot

Prise en main grautite

Pour utiliser Copilot, vous aurez besoin d'un compte personnel GitHub avec accès à un plan Copilot. Vous pouvez :

  • Commencez avec Copilote gratuit pour découvrir des fonctionnalités limitées sans souscrire à un abonnement.
  • Passez à Copilot Pro ou Copilot Pro+ pour débloquer davantage de fonctionnalités, de modèles et de limites de requêtes.

Pour plus d'informations sur les différents plans pour GitHub Copilot, voir Plans for GitHub Copilot.

Asking your first question

  1. On GitHub, navigate to a repository and open a file.

  2. Click the Copilot icon () at the top right of the file view.

    Screenshot of the Copilot button, highlighted with a dark orange outline, at the top of the file view.

  3. Type a question in the "Ask Copilot" box at the bottom of the chat panel and press Enter.

    For example, you could enter:

    • Explain this file.
    • How could I improve this code?
    • How can I test this code?

    Copilot responds to your request in the panel.

  4. 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.

Other questions you can ask

There are many more things you can do with GitHub Copilot Chat dans GitHub. For example:

  • Ask a general question about software development
  • Ask exploratory questions about a repository
  • Ask a question about a knowledge base
  • Find out about the changes in a pull request
  • Ask a question about a specific issue or commit

For more information, see Asking GitHub Copilot questions in GitHub.

Next steps

GitHub Copilot fournit des suggestions de codage lorsque vous saisissez un texte dans votre éditeur. Vous pouvez également poser des questions relatives au codage à Copilot, telles que la meilleure manière de développer un code, la correction d’un bogue ou le fonctionnement du code de quelqu’un d’autre. Pour plus de détails sur ce que Copilot peut faire, consultez 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.

S’inscrire à GitHub Copilot

Prise en main grautite

Pour utiliser Copilot, vous aurez besoin d'un compte personnel GitHub avec accès à un plan Copilot. Vous pouvez :

  • Commencez avec Copilote gratuit pour découvrir des fonctionnalités limitées sans souscrire à un abonnement.
  • Passez à Copilot Pro ou Copilot Pro+ pour débloquer davantage de fonctionnalités, de modèles et de limites de requêtes.

Pour plus d'informations sur les différents plans pour GitHub Copilot, voir Plans for GitHub Copilot.

Prerequisites

Use Copilot in Terminal Chat

After you've installed Windows Terminal Canary, you can use Copilot in Terminal Chat to ask command line-related questions.

  1. Open Settings from the dropdown menu.

    Screenshot of the dropdown menu in the Windows Terminal with the Settings item highlighted.

  2. Go to the Terminal Chat (Experimental) setting.

    Screenshot of the Settings menu in the Windows Terminal with the Terminal Chat (Experimental) item highlighted.

  3. Under Service Providers, select GitHub Copilot and Authenticate via GitHub to sign in.

Chat with GitHub Copilot

Remarque

Si vous avez accès à GitHub Copilot via votre organisation, vous ne pourrez pas utiliser GitHub Copilot dans Windows Terminal si le propriétaire de votre organisation a désactivé GitHub Copilot dans l’interface de ligne de commande CLI. Consultez Managing policies for Copilot in your organization.

  1. Open Terminal Chat (Experimental) in the dropdown menu.

  2. In the Terminal Chat chat window, type how do i list all markdown files in my directory then press Enter.

    Copilot's answer is displayed below your question.

  3. Click on an answer to insert it to the command line.

Next steps

GitHub Copilot fournit des suggestions de codage lorsque vous saisissez un texte dans votre éditeur. Vous pouvez également poser des questions relatives au codage à Copilot, telles que la meilleure manière de développer un code, la correction d’un bogue ou le fonctionnement du code de quelqu’un d’autre. Pour plus de détails sur ce que Copilot peut faire, consultez What is GitHub Copilot?.

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.

S’inscrire à GitHub Copilot

Prise en main grautite

Pour utiliser Copilot, vous aurez besoin d'un compte personnel GitHub avec accès à un plan Copilot. Vous pouvez :

  • Commencez avec Copilote gratuit pour découvrir des fonctionnalités limitées sans souscrire à un abonnement.
  • Passez à Copilot Pro ou Copilot Pro+ pour débloquer davantage de fonctionnalités, de modèles et de limites de requêtes.

Pour plus d'informations sur les différents plans pour GitHub Copilot, voir Plans for GitHub Copilot.

Prerequisites

Chat with GitHub Copilot

After you've installed the GitHub Copilot extension, you can ask Copilot coding-related questions.

Remarque

Si vous avez accès à GitHub Copilot via votre organisation, vous ne pourrez pas utiliser GitHub Copilot Chat si le propriétaire de votre organisation a désactivé le chat. Consultez Managing policies for Copilot in your organization.

  1. Open an existing code file.

  2. Open the Chat view from the Activity Bar.

    Screenshot of the Chat icon in the VS Code Activity Bar.

  3. At the bottom of the chat view, in the chat input field, type: explain this file.

  4. Press Enter.

    Copilot replies in the chat view.

  5. In the editor, select one or more lines of code that are not commented.

  6. In the chat input field, type: add comments to these lines.

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

    Screenshot of the "Insert at Cursor" icon in the chat view.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

  1. Open Visual Studio Code.

  2. Dans Visual Studio Code, créez un fichier JavaScript ( *.js).

  3. Dans le fichier JavaScript, tapez l’en-tête de fonction suivant.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

    GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.

  4. Pour accepter la suggestion, appuyez sur Tab.

Next steps

GitHub Copilot fournit des suggestions de codage lorsque vous saisissez un texte dans votre éditeur. Vous pouvez également poser des questions relatives au codage à Copilot, telles que la meilleure manière de développer un code, la correction d’un bogue ou le fonctionnement du code de quelqu’un d’autre. Pour plus de détails sur ce que Copilot peut faire, consultez What is GitHub Copilot?.

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.

S’inscrire à GitHub Copilot

Prise en main grautite

Pour utiliser Copilot, vous aurez besoin d'un compte personnel GitHub avec accès à un plan Copilot. Vous pouvez :

  • Commencez avec Copilote gratuit pour découvrir des fonctionnalités limitées sans souscrire à un abonnement.
  • Passez à Copilot Pro ou Copilot Pro+ pour débloquer davantage de fonctionnalités, de modèles et de limites de requêtes.

Pour plus d'informations sur les différents plans pour GitHub Copilot, voir Plans for GitHub Copilot.

Prerequisites

  • Version compatible de Visual Studio. Pour utiliser GitHub Copilot dans Visual Studio, vous devez avoir installé la version 2022 17.8 ou ultérieure de Visual Studio pour Windows. Pour plus d’informations, consultez Installer Visual Studio dans la documentation Microsoft.
  • Extension GitHub Copilot pour Visual Studio. Pour obtenir des instructions sur l’installation de l’extension Copilot, consultez Installer GitHub Copilot dans Visual Studio dans la documentation Microsoft.
  • Ajoutez votre compte GitHub à Visual Studio. Consultez Ajouter vos comptes GitHub à votre trousseau Visual Studio dans la documentation Microsoft.

Chat with GitHub Copilot

After you've installed the GitHub Copilot extension, you can ask Copilot coding-related questions.

Remarque

Si vous avez accès à GitHub Copilot via votre organisation, vous ne pourrez pas utiliser GitHub Copilot Chat si le propriétaire de votre organisation a désactivé le chat. Consultez Managing policies for Copilot in your organization.

  1. Open an existing code file.

  2. In the Visual Studio menu bar, click View, then click GitHub Copilot Chat.

  3. In the Copilot Chat window, type what does this file do then press Enter.

    Copilot's answer is displayed below your question.

  4. Select a line of code in the editor.

  5. In the Copilot Chat window, type explain this line then press Enter.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

  1. Open Visual Studio.

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

  3. Dans le fichier JavaScript, tapez l’en-tête de fonction suivant.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

    GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.

  4. Pour accepter la suggestion, appuyez sur Tab.

Next steps

GitHub Copilot fournit des suggestions de codage lorsque vous saisissez un texte dans votre éditeur. Vous pouvez également poser des questions relatives au codage à Copilot, telles que la meilleure manière de développer un code, la correction d’un bogue ou le fonctionnement du code de quelqu’un d’autre. Pour plus de détails sur ce que Copilot peut faire, consultez What is GitHub Copilot?.

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.

S’inscrire à GitHub Copilot

Prise en main grautite

Pour utiliser Copilot, vous aurez besoin d'un compte personnel GitHub avec accès à un plan Copilot. Vous pouvez :

  • Commencez avec Copilote gratuit pour découvrir des fonctionnalités limitées sans souscrire à un abonnement.
  • Passez à Copilot Pro ou Copilot Pro+ pour débloquer davantage de fonctionnalités, de modèles et de limites de requêtes.

Pour plus d'informations sur les différents plans pour GitHub Copilot, voir Plans for GitHub Copilot.

Prerequisites

Chat with GitHub Copilot

After you've installed the GitHub Copilot plugin, you can ask Copilot coding-related questions.

Remarque

Si vous avez accès à GitHub Copilot via votre organisation, vous ne pourrez pas utiliser GitHub Copilot Chat si le propriétaire de votre organisation a désactivé le chat. Consultez Managing policies for Copilot in your organization.

  1. Open an existing code file.

  2. Open the Copilot Chat window by clicking the Copilot Chat icon at the right side of the JetBrains IDE window.

    Screenshot of the Copilot Chat icon in the Activity Bar.

  3. In the Copilot Chat window, type what does this file do then press Enter.

    Copilot's answer is displayed below your question.

  4. Select a line of code in the editor.

  5. In the Copilot Chat window, type explain this line then press Enter.

Get your first code completion suggestion

The following example uses JavaScript, however other languages will work similarly. GitHub Copilot fournit des suggestions pour de nombreux langages et un large éventail d’infrastructures, mais fonctionnent particulièrement bien pour Python, JavaScript, TypeScript, Ruby, Go, C# et C++. GitHub Copilot peut également aider à générer des requêtes pour les bases de données ou des suggestions pour les API et cadres. Il peut aider aussi au développement d’une infrastructure en tant que code.

  1. In your JetBrains editor, create a new JavaScript (*.js) file.

  2. Dans le fichier JavaScript, tapez l’en-tête de fonction suivant.

    JavaScript
    function calculateDaysBetweenDates(begin, end) {
    

    GitHub Copilot will automatically suggest an entire function body in grayed text. The exact suggestion may vary.

  3. Pour accepter la suggestion, appuyez sur Tab.

Next steps