If you allow GitHub Copilot to make suggestions that match publicly available code, Copilot will display references to any matching code that is found.
This version of this article is for Copilot in JetBrains IDEs. For Copilot on other platforms, click the appropriate tab above.
This version of this article is for Copilot in Visual Studio Code. For Copilot on other platforms, click the appropriate tab above.
This version of this article is for Copilot on the GitHub website. For Copilot on other platforms, click the appropriate tab above.
References to matching code are currently only available in JetBrains IDEs, Visual Studio Code, and on the GitHub website.
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.
If you've allowed suggestions that match public code, GitHub Copilot can provide you with details of the code that a suggestion matches. This happens:
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.
When you accept a code completion suggestion that matches code in a public GitHub repository, an entry is added to the JetBrains log. The log entry includes the URLs of files containing matching code, and the name of the license that applies to that code, if any was found. This allows you to review these references and decide how to proceed. For example, you can decide what attribution to use, or whether you want to remove this code from your project.
Note
When Copilot Chat provides a response that includes code that matches code in a public GitHub repository, this is indicated at the end of the response with a link to display details of the matched code in the editor.
Typically, matches to public code occur infrequently, so you should not expect to see code references in many Copilot Chat responses.
When you accept a code completion suggestion that matches code in a public GitHub repository, an entry is added to a GitHub Copilot log. The log entry includes a link to a page on GitHub.com where you can view references to similar code in public GitHub repositories.
The linked web page includes details of any license identified for the repository where the matching code was found. Having reviewed the references, you can decide how to proceed. For example, you can decide what attribution to use, or whether you want to remove this code from your project.
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.
You can view code references in the log file for your JetBrains IDE.
In your JetBrains IDE, select Help > Show Log in Finder/Explorer.
The log file is displayed in your file manager. For example, for IntelliJ IDEA the log file is called idea.log.
idea.log
Open the log file in your JetBrains IDE.
Search for "[Public Code References]."
2025-02-26 09:22:12,045 [5581906] INFO - #copilot - [Public Code References] Text found matching public code in file://Users/mona-lisa/git-repos/test-repo/fizzbuzz.js [Ln 1, Col 10] near fizzBuzz() ...: 1) [NOASSERTION] https://github.com/nixsticks/todos/blob/ae427a721c7784da64a619ba17f60637fe1cc819/Loops/fizzbuzz/fizzbuzz.js 2) [GPL-3.0] https://github.com/voloslg/algocasts/blob/34b423517486f908ca167b390d3b8bd05653829f/exercises/fizzbuzz/index.js
The log entry includes the following details:
NOASSERTION
You can verify that code referencing is working by prompting Copilot to add some commonly used code and checking the output in the log file for your IDE.
Display the log file for your JetBrains IDE, as described in the previous section.
Create a file called fizz-buzz.js and open it in the JetBrains editor.
fizz-buzz.js
In the editor, type:
function fizzBuzz()
With a space after the closing parenthesis.
GitHub Copilot should suggest code to complete the function. Typically the suggestion will be a common implementation of the fizz buzz algorithm that will match publicly available code on the GitHub website.
Accept the suggestion by pressing Tab.
Check whether a "[Public Code References]" entry has been added to the log file.
You can access code references from one of the GitHub Copilot logs in Visual Studio Code.
In Visual Studio Code, open the Output window by selecting View > Output from the menu bar.
In the dropdown menu at the right of the Output window, select GitHub Copilot Log.
Leave the GitHub Copilot Log view displayed while you use GitHub Copilot in Visual Studio Code.
When you accept a code completion suggestion that matches code in a public GitHub repository, an entry is added to the log.
The GitHub Copilot log is flushed when you close the editor.
In the log entry, Ctrl+click (Windows/Linux) or Command+click (Mac) the link to view the code references on GitHub.com.
The page lists the matches that were found, showing an excerpt from the relevant file. You can click on the file name to view the whole file.
Matches may be found in multiple repositories with different, sometimes conflicting, licenses. You can use the checkboxes on the left of the page to show only the matches associated with a particular license.
You should review all license information within a repository to verify that it applies to the matching code, as repositories may contain multiple licenses and these licenses are subject to human and non-human error.
The web page displaying the full set of details will remain available for three months.
You can verify that code referencing is working by prompting Copilot to add some commonly used code and checking the output in the Copilot log.
In Visual Studio Code, create a file called fizz-buzz.js.
Open the Output window by selecting View > Output from the menu bar.
If code referencing finds a match to public code, a log entry is added to the GitHub Copilot Log view.
If a response in Copilot Chat includes matching code, this is indicated at the end of the response by the following text:
Similar code found with n license types - View matches
Click View matches to display details of the matched code in a new editor tab.
For each example of matching code, the editor displays:
In the editor, Ctrl+click (Windows/Linux) or Command+click (Mac) a URL to view the full file on GitHub.com.
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.