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, organization or enterprise settings. For more information, see Managing Copilot policies as an individual subscriber, Managing policies for Copilot in your organization or Managing policies and features for Copilot in your enterprise.
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:
-
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.
-
Click the name of a repository to display that repository on GitHub.com.