[go: up one dir, main page]

Skip to main content

Using GitHub Copilot code review

Learn how to request a code review from GitHub Copilot.

Introduction

GitHub Copilot can review your code and provide feedback. Where possible, Copilot's feedback includes suggested changes which you can apply with a couple of clicks.

For a full introduction to GitHub Copilot-Code Review, see About Copilot code review.

Using Copilot Code Review

These instructions explain how to use Copilot Code Review in the GitHub website. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  1. On GitHub.com, create a pull request or navigate to an existing pull request.

  2. Open the Reviewers menu, then select Copilot.

    Screenshot of selecting 'Copilot' from the 'Reviewers' menu.

  3. Wait for Copilot to review your pull request. This usually takes less than 30 seconds.

  4. Scroll down and read through Copilot's comments.

    Screenshot of a code review left by Copilot.

    Copilot always leaves a "Comment" review, not an "Approve" review or a "Request changes" review. This means that Copilot's reviews do not count toward required approvals for the pull request, and Copilot's reviews will not block merging changes. For more details, see Einen Pull Request mit erforderlichen Reviews genehmigen.

  5. Copilot's review comments behave like review comments from humans. You can add reactions to them, comment on them, resolve them and hide them.

    Any comments you add to Copilot's review comments will be visible to humans, but they won't be visible to Copilot, and Copilot won't reply.

Working with suggested changes provided by Copilot

Where possible, Copilot's feedback includes suggested changes which you can apply with a couple of clicks.

If you're happy with the changes, you can accept a single suggestion from Copilot and commit it, or accept a group of suggestions together in a single commit. For more information, see Feedback in Deinen Pull Request aufnehmen.

Providing feedback on Copilot's reviews

You can provide feedback on Copilot's comments directly within each comment. We use this information to improve the product and the quality of Copilot's suggestions.

  1. On a pull request review comment from Copilot, click the thumbs up (👍) or thumbs down (👎) button.

    Screenshot showing a Copilot Code Review comment with the thumbs up and thumbs down buttons.

  2. If you click the thumbs down button, you're asked to provide additional information. You can, optionally, pick the reason for your negative feedback and leave a comment before clicking Submit feedback.

    Screenshot of the form for providing additional information when you give negative feedback on a comment from Copilot.

Requesting a re-review from Copilot

When you push changes to a pull request that Copilot has reviewed, it won't automatically re-review your changes.

To request a re-review from Copilot, click the button next to Copilot's name in the Reviewers menu. For more information, see Pull-Request-Review anfordern.

Hinweis

When re-reviewing a pull request, Copilot may repeat the same comments again, even if they have been dismissed with the "Resolve conversation" button or downvoted with the thumbs down (👎) button.

Enabling automatic reviews

By default, you manually request a review from Copilot on each pull request, in the same way you would request a review from a human. However, you can set up Copilot to automatically review all pull requests. See Configuring automatic code review by Copilot.

Customizing Copilot's reviews with custom instructions

Hinweis

Benutzerdefinierte Anweisungen für Copilot Code Review befinden sich in der public preview. Änderungen sind vorbehalten.

Dieses Feature ist mit dem Copilot Pro-, Copilot Pro+-, Copilot Business- und Copilot Enterprise-Plan verfügbar.

Wenn du einen Copilot Business- oder Copilot Enterprise-Plan verwendest, muss die Organisation oder das Unternehmen, die bzw. das den Plan bereitstellt, während der public preview die Einstellung Opt in to preview features aktiviert haben. Weitere Informationen findest du unter Managing policies and features for Copilot in your organization oder Managing policies and features for Copilot in your enterprise.

Passe das Verhalten von Copilot Code Review an, indem du eine benutzerdefinierte Datei mit Anweisungen für das Repository hinzufügst. Erstelle dazu in deinem Repository eine .github/copilot-instructions.md-Datei, und füge Text in natürlicher Sprache hinzu, den Copilot beim Überprüfen von Code berücksichtigen soll. Dabei handelt es sich um dasselbe copilot-instructions.md-Element, das von Copilot Chat verwendet werden. Weitere Informationen findest du unter Adding repository custom instructions for GitHub Copilot.

Um benutzerdefinierte Anweisungen für den Review zu aktivieren oder zu deaktivieren, wechsle zu den Einstellungen deines Repositorys, navigiere anschließend unter Copilot zu Review, und aktiviere die Option „Benutzerdefinierte Anweisungen verwenden beim Überprüfen von Pull Requests verwenden“.

Beispiel

Dieses Beispiel einer .github/copilot-instructions.md-Datei enthält drei Anweisungen, die auf alle Copilot Code Review im Repository angewendet werden.

When performing a code review, respond in Spanish.

When performing a code review, follow our internal security checklist.

When performing a code review, focus on readability and avoid nested ternary operators.

Customizing Copilot's reviews with coding guidelines

Hinweis

Das Feature für benutzerdefinierte Programmierrichtlinien ist nur für den Copilot Enterprise-Plan verfügbar und derzeit auf ausgewählte Kunden beschränkt.

Wenn du Copilot Code Review zum Überprüfen von Änderungen in Visual Studio Code oder auf der Website von GitHub verwendest, kannst du den Review von Copilot mit in natürlicher Sprache geschriebenen benutzerdefinierten Programmierrichtlinien anpassen. Copilot erzeugt basierend auf deinen Programmierrichtlinien Feedback, wenn dein Code überprüft wird. Weitere Informationen finden Sie unter Configuring coding guidelines for GitHub Copilot code review.

Auf einer Programmierrichtlinie basierende Kommentare enthalten eine Nachricht, in der die Quelle hervorgehoben wird.

Using Copilot Code Review

These instructions explain how to use Copilot Code Review in Visual Studio Code. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

Hinweis

Copilot Code Review is available in Visual Studio Code with version 0.22 or later of the GitHub Copilot Chat extension.

Reviewing a selection of code

You can request an initial review of a highlighted selection of code in Visual Studio Code.

  1. In Visual Studio Code, select the code you want to review.

  2. Open the VS Code Command Palette

    • For Mac:
      • Use: Shift+Command+P
    • For Windows or Linux:
      • Use Ctrl+Shift+P
  3. In the command palette, search for and select GitHub Copilot: Review and Comment.

    Screenshot of the command palette in Visual Studio Code with the GitHub Copilot: Review and Comment command selected.

  4. Wait for Copilot to review your changes. This usually takes less than 30 seconds.

  5. If Copilot has any comments, they will be shown inline in your file, and in the Problems tab.

Reviewing all uncommitted changes

You can request a review of your uncommitted changes in Visual Studio Code.

  1. In VS Code, click the Source Control button in the Activity Bar.

  2. At the top of the Source Control view, hover over CHANGES, then click the Copilot Code Review - Uncommitted Changes button.

    Screenshot of the "Source Control" view. The code review button is outlined in dark orange.

  3. Wait for Copilot to review your changes. This usually takes less than 30 seconds.

  4. If Copilot has any comments, they will be shown inline in your file(s), and in the Problems tab.

Working with suggested changes provided by Copilot

Where possible, Copilot's feedback includes suggested changes which you can apply with a single click.

Screenshot of a comment from Copilot in Visual Studio Code with a suggested change.

If you're happy with the change, you can accept a suggestion from Copilot by clicking the Apply and Go To Next button. Any changes you apply will not be automatically committed.

If you don't want to apply Copilot's suggested change, click the Discard and Go to Next button.

Providing feedback on Copilot's reviews

You can provide feedback on Copilot's comments directly within each comment. We use this information to improve the product and the quality of Copilot's suggestions.

To provide feedback, hover over the comment and click the thumbs up or thumbs down button.

Screenshot of a comment from Copilot in Visual Studio Code with feedback buttons displayed. The buttons are outlined in dark orange.

Customizing Copilot's reviews with custom instructions

Hinweis

Benutzerdefinierte Anweisungen für Copilot Code Review befinden sich in der public preview. Änderungen sind vorbehalten.

Dieses Feature ist mit dem Copilot Pro-, Copilot Pro+-, Copilot Business- und Copilot Enterprise-Plan verfügbar.

Wenn du einen Copilot Business- oder Copilot Enterprise-Plan verwendest, muss die Organisation oder das Unternehmen, die bzw. das den Plan bereitstellt, während der public preview die Einstellung Opt in to preview features aktiviert haben. Weitere Informationen findest du unter Managing policies and features for Copilot in your organization oder Managing policies and features for Copilot in your enterprise.

Passe das Verhalten von Copilot Code Review an, indem du eine benutzerdefinierte Datei mit Anweisungen für das Repository hinzufügst. Erstelle dazu in deinem Repository eine .github/copilot-instructions.md-Datei, und füge Text in natürlicher Sprache hinzu, den Copilot beim Überprüfen von Code berücksichtigen soll. Dabei handelt es sich um dasselbe copilot-instructions.md-Element, das von Copilot Chat verwendet werden. Weitere Informationen findest du unter Adding repository custom instructions for GitHub Copilot.

Um benutzerdefinierte Anweisungen für den Review zu aktivieren oder zu deaktivieren, wechsle zu den Einstellungen deines Repositorys, navigiere anschließend unter Copilot zu Review, und aktiviere die Option „Benutzerdefinierte Anweisungen verwenden beim Überprüfen von Pull Requests verwenden“.

Beispiel

Dieses Beispiel einer .github/copilot-instructions.md-Datei enthält drei Anweisungen, die auf alle Copilot Code Review im Repository angewendet werden.

When performing a code review, respond in Spanish.

When performing a code review, follow our internal security checklist.

When performing a code review, focus on readability and avoid nested ternary operators.

Customizing Copilot's reviews with coding guidelines

Hinweis

Das Feature für benutzerdefinierte Programmierrichtlinien ist nur für den Copilot Enterprise-Plan verfügbar und derzeit auf ausgewählte Kunden beschränkt.

Wenn du Copilot Code Review zum Überprüfen von Änderungen in Visual Studio Code oder auf der Website von GitHub verwendest, kannst du den Review von Copilot mit in natürlicher Sprache geschriebenen benutzerdefinierten Programmierrichtlinien anpassen. Copilot erzeugt basierend auf deinen Programmierrichtlinien Feedback, wenn dein Code überprüft wird. Weitere Informationen finden Sie unter Configuring coding guidelines for GitHub Copilot code review.

Auf einer Programmierrichtlinie basierende Kommentare enthalten eine Nachricht, in der die Quelle hervorgehoben wird.

Prerequisite

To use Copilot Code Review, you must use Visual Studio version 17.14 or later. See the Visual Studio downloads page.

Using Copilot Code Review

These instructions explain how to use Copilot Code Review in Visual Studio. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  1. In the Git Changes window, click Review changes with Copilot. This button appears as a comment icon with a sparkle.

  2. Copilot will begin reviewing your changes. After a few moments, a link showing the number of code review comments appears in the Git Changes window.

  3. Click the link to view and navigate the comments. If no issues are found, you’ll see the message: Copilot did not comment on any files.

  4. Copilot displays comments in your code with a summary of each potential issue. You can:

    • Review and make changes based on the suggestions.
    • Dismiss a comment using the downward arrow in the top-right corner of the comment box.
  5. To remove all review comments, click next to the code review link in the Git Changes window.

For more information on enabling and configuring Copilot Code Review in Visual Studio, see Review local changes with Copilot Chat in the Visual Studio documentation.

Using Copilot Code Review

These instructions explain how to use Copilot Code Review in GitHub Mobile. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

  1. In GitHub Mobile, open a pull request.
  2. Scroll down to the Reviews section and expand it.
  3. Click Request Reviews.
  4. Add Copilot as a reviewer, then click Done.

Copilot will review the changes and provide feedback.