February 19th, 2025

Introducing Code Referencing for GitHub Copilot Completions in Visual Studio

When GitHub Copilot completions (or “gray text”) pop up on your screen, have you ever wondered where does the completions come from and worried about if it matches with public code leading to license issues? If you have, we are introducing code referencing to support you and provide more transparency!

We are excited to announce that code referencing is available now for GitHub Copilot Completions in Visual Studio 2022 17.13, a feature previously introduced in Copilot Chat (see previous blog post). So you can feel more confident when accepting the completions!

Learn about Completions Public Code Match

When you accept a completion that matches code in a public GitHub repository for the first time in your solution, a toast notification will appear on the bottom right of your editor.

A toast notification that pops up on the bottom right corner of Visual Studio with the title: Found similar code in public repos. Body text include: Copilot completion code matches will appear in the Copilot output window pane. There are two buttons in the toast: on the left, View code matches and on the right, More info.

From the toast, you can view code matches in the GitHub Copilot Output Window, where includes more detailed information about the license type and a link to GitHub.com, where the original public code file lives. You can click on the link to read more about the original file and make informed decisions, such as including code attribution or removing the code from your project.

The Visual Studio Output Window, showing output from GitHub Copilot. One output message is highlighted with a red rectangular box. The highlighted output message is [Completions Public Code Match Information] Similar code with license type [MIT], followed by a link to github.

From the toast, you can also learn more information about public code match and how to manage it as an individual subscriber here: Managing Copilot policies as an individual subscriber.

In your future coding workflow, you can always check for any public code match by opening the Output Window (Ctrl+Alt+O) and searching for “Completions Public Code Match Information.”

Note:

  • Code referencing for completions only occurs for accepted Copilot completions. Any code you have written, as well as completions you have modified or dismissed, are not checked for public code matches.
  • Typically, matches to public code occur in less than one percent of Copilot completions, so you should not expect to see code references for many completions. This estimation is higher if you work in open-source repositories.

Configure Code Referencing

Note: If you are a member of an organization on GitHub Enterprise Cloud and have been assigned a GitHub Copilot seat through your organization, you may not be able to configure suggestions matching public code in your personal account settings. Your settings will be inherited from your organization or enterprise.

If you are an individual subscriber, your personal settings for GitHub Copilot include an option to either allow or block code suggestions that match publicly available code:

  • Block suggestions matching public code: GitHub Copilot checks code suggestions with their surrounding code against public code on GitHub. If there’s a match or near match, the suggestion is not shown.
  • Allow suggestions matching public code: When Copilot suggests matching code, you can view details of the matches and navigate to the relevant repositories on GitHub.

To adjust your settings:

  1. In the upper-right corner of any page on GitHub, click your profile photo, then click Your Copilot.
  2. Next to Suggestions matching public code, use the dropdown menu to select Allow or Block.

For more information, see Managing Copilot policies as an individual subscriber.

Code with More Confidence and Transparency

This new functionality offers developers greater transparency on their code completions (or “gray text”) by providing detailed information on any public code matches found. Prior to this change, Copilot completions with public code match were automatically blocked. Now, developers have the choice to access more code completions and receive sufficient information about any public code matches, enabling them to make informed decisions.

Try It Out Today

We believe this new code referencing feature in Copilot Completions improves your development experience with more transparency and informed choices. Give it a try in Visual Studio 17.13 or later, and share your feedback with us.

We appreciate the time you’ve spent reporting issues/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve. Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via Developer Community: report any bugs or issues via report a problem and share your suggestions for new features or improvements to existing ones.

Stay connected with the Visual Studio team by following us on YouTube, Twitter, LinkedIn, Twitch and on Microsoft Learn.

Author