Skip to main content

Поиск общедоступного кода, соответствующего предложениям GitHub Copilot

Если вы разрешаете GitHub Copilot делать предложения, соответствующие общедоступному коду, Copilot будет отображать ссылки на любой найденный код сопоставления.

This version of this article is for Copilot on the GitHub website. For the Visual Studio Code version of this article, click the tab above.

Limitations

References to matching code are currently only available in Visual Studio Code and on the GitHub website.

Prerequisites

References to matching code are only generated if Copilot is configured to allow suggestions that match publicly available code. This is configured in either your personal or organization settings. For more information, see Managing Copilot policies as an individual subscriber or Managing policies for Copilot in your organization.

About code referencing in GitHub Copilot

If you've allowed suggestions that match public code, then whenever a response from Copilot Chat includes matching code, details of the matches will be included in the response.

This feature is called code referencing.

Note

Typically, matches to public code occur infrequently, so you should not expect to see code references in many Copilot Chat responses.

How code referencing finds matching code

Copilot code referencing searches for matches by taking the code suggestion, plus some of the code that will surround the suggestion if it is accepted, and comparing it against an index of all public repositories on GitHub.com. Code in private GitHub repositories, or code outside of GitHub, is not included in the search process. The search index is refreshed every few months. As a result, newly committed code, and code from public repositories deleted before the index was created, may not be included in the search. For the same reason, the search may return matches to code that has been deleted or moved since the index was created.

View code references for Copilot Chat

When Copilot Chat provides a response that includes code that matches code in a public GitHub repository, this is indicated beneath the code suggestion:

< > Public code references from n repositories

To see details of the matching code:

  1. Click the "Public code references..." text, under the code suggestion.

    A list of GitHub repositories containing matching code is displayed in a dropdown, together with licensing information, if found.

    Screenshot of a code completion suggestion in Copilot Chat with a link to view code references.

  2. Click the name of a repository to display that repository on GitHub.com.