Public Code Matching in Copilot: Block or Show References
30-second answer
When a Copilot suggestion matches code in a public GitHub repository (a match of about 150 characters or more), the "Suggestions matching public code" policy decides what happens. Block hides the matching suggestion. Allow shows it and adds a code reference: the matching repositories and their licences, in VS Code's Output › GitHub Copilot Log (Code References) and in chat answers. Organization owners set it for Business and Enterprise seats (an enterprise can enforce it); individuals on Free, Pro or Pro+ set it in their own Copilot settings. Either way, you're responsible for what you accept.
Simulate it » No Azure account neededExam objective: 6.2.1 Enable suggestions matching public code filtering. (Skills measured as of August 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
The <strong>public code</strong> policy decides what happens when a suggestion matches code in public repositories (about 150 characters or more). Organizations set it for their seats; individuals set it in their own settings.
👆 Click the glowing item on screen to continue
Read the steps as text
- The public code policy decides what happens when a suggestion matches code in public repositories (about 150 characters or more). Organizations set it for their seats; individuals set it in their own settings.
- With Block, the matching suggestion simply isn’t shown.
- With Allow, the suggestion is shown and Copilot adds a code reference: the matching repositories and their licences, in the Output panel or the chat answer. You decide whether to use it and how to attribute it.
🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.
🖱️ Drag to rotate · scroll or pinch to zoom
Suggestions matching public code
A policy decides what happens when a suggestion matches public code: Block hides it; Allow shows it with a code reference (repository and licence) so you can decide.
🤔 What happens if…
Read this tour as text
- Plans and seats. Individuals use Copilot Free, Pro or Pro+. Organizations buy Copilot Business per seat; Copilot Enterprise adds features on GitHub Enterprise Cloud. Admins assign seats to users or teams.
- Policies flow down. An enterprise can enforce a Copilot policy for all its organizations or leave the choice to each organization. Policies cover features (chat in the IDE, on github.com, the CLI, code review, agents), models and MCP.
- Seats light up Copilot. A developer gets Copilot once they have a seat. Remove the seat and Copilot stops at the end of the billing cycle.
- Suggestions matching public code. A policy decides what happens when a suggestion matches public code: Block hides it; Allow shows it with a code reference (repository and licence) so you can decide.
- Content exclusions. Repository, organization and enterprise admins can exclude files and paths. Copilot won’t use them as context or suggest inside them in supported IDEs. Changes can take up to 30 minutes to reach editors.
- Audit log and metrics. Copilot settings changes, seat assignments and content exclusion changes appear in the audit log. Usage metrics and the REST API show adoption and activity.
- Responsible use. Policies reduce risk, but the developer still owns the output: review it, test it, scan it for vulnerabilities and check licences before it ships.
- Troubleshooting. No suggestions? Check the seat and sign-in, whether the file is excluded, whether the language is disabled in settings, the public code filter, network or proxy settings, and the Copilot logs in the IDE.
A free terminal with GitHub Copilot CLI, git and gh. No tasks: install the CLI, start a session, try slash commands and tool permissions, or call the seats API.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A suggestion looks a lot like a popular open-source project.
😊 THE SOLUTION
Block matches with public code, or allow them with code references.
- Copied-looking suggestions✓ Block matching suggestions
- Need to know the source✓ Allow + code reference
- Different rules per person✓ Org policy for seats
Start with a question
Copilot just suggested 30 lines that look a lot like a popular open-source library. Can you use them?
Maybe. It depends on the licence of the code it matches, and whether you’ll follow it.
Most of what Copilot suggests is new, stitched together from patterns. But now and then a longer suggestion matches code that already exists in a public repository. If that repository is MIT-licensed, you’re probably fine with attribution. If it’s GPL, your legal team will want a word.
The problem is you can’t tell by looking. So Copilot gives your organization a choice: hide those matches entirely, or show them with a note saying where the code came from and under which licence.
Explain it like I’m 10
The technical explanation
How a match is found
Before a suggestion reaches your editor, Copilot’s post-processing compares it with code in public GitHub repositories. A match means a stretch of about 150 characters or more that’s the same. Short, common code like for (let i = 0; i < n; i++) doesn’t trigger it.
Block or Allow
| Block | Allow | |
|---|---|---|
| Matching suggestion shown? | No | Yes |
| Code reference? | — | Yes: repository URL and licence |
| Where | Suggestion simply doesn’t appear | Inline: Output › GitHub Copilot Log (Code References). Chat: listed in the answer |
| Good for | Teams that want no licence decisions at the keyboard | Teams that want visibility and know how to attribute |
A code reference for an inline suggestion looks something like this in the Output panel:
[GitHub Copilot] Code reference
Similar code found with 1 license type: MIT
github.com/example/cart-utils/blob/main/total.js
Who sets it
| Plan | Who controls the setting | Where |
|---|---|---|
| Copilot Free, Pro, Pro+ | You | Your personal Copilot settings on github.com |
| Copilot Business | Organization owner | Organization settings › Copilot › Policies |
| Copilot Enterprise | Enterprise owner (enforce) or each organization | Enterprise policies, or the org’s Copilot policies when the enterprise leaves “No policy” |
If a developer gets a seat from an organization, the organization’s choice applies. They can’t override it in personal settings.
Architect level Why Block isn't a legal guarantee
Block hides suggestions the filter detects as matches. It doesn’t promise that nothing Copilot writes resembles existing code, and it doesn’t check code you paste in yourself. It lowers the risk; it doesn’t remove responsibility. That’s why many teams pair it with licence scanning on dependencies and a clear rule on attribution. For the contract side, Business and Enterprise terms include IP indemnity, with conditions that the terms spell out.
Real-world business scenario
Contoso (fictional)
- The problem
- Contoso's open-source office allowed MIT and Apache code with attribution but not GPL in the closed-source contoso-shop. Developers had no way to tell where a long Copilot suggestion came from.
- What they used
- The enterprise enforced Suggestions matching public code: Allow, so every match came with a code reference, and the team added a pull request checklist item to note any referenced code and its licence.
- Why that choice
- Developers saw the licence at the moment of choice, and the open-source office could audit attributions instead of guessing.
- The result
- Two GPL matches were caught and rewritten before merge in the first month, and MIT snippets carry their attribution.
When to use it and when not to
✓ Use it when…
- Block, when you want the simplest rule and no licence decisions at the keyboard.
- Allow, when developers should see where similar code exists and can attribute it properly.
- Enterprise enforcement, when every organization must use the same setting.
✕ Think twice when…
- Treating Block as proof that no code resembles anything public.
- Treating a code reference as permission. Read the licence it shows.
- Asking developers with organization seats to change it themselves. It's an admin setting.
↔ Alternatives to consider
- Dependency review and licence scanning for the packages you add.
- Content exclusions when the worry is your own sensitive files, not public code.
Test yourself with exercises
5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between Block and Allow for public code matches?
Model answer
Block means I never see a suggestion that matches public code. Allow means I see it, and Copilot tells me which public repositories have similar code and under which licence, so I can decide.
Interviewer follows up
Where do you see that information in VS Code?
You
For inline suggestions, in the Output panel under GitHub Copilot Log (Code References). In chat, the answer itself lists the reference.
Intermediate Roughly how long does a match have to be for the filter to apply?
Model answer
About 150 characters. Short, common lines like a for loop don't count. It's aimed at longer chunks that look copied.
Experienced developer A developer on Copilot Business wants to change the public code setting for themselves. Can they?
Model answer
No. For organization seats the organization owner sets it in the Copilot policies, and if the enterprise enforces it, the organization can't change it either. The developer would need to ask the admin. Only individual plans control it in personal settings.
Interviewer follows up
Where does the admin set it?
You
Organization settings, Copilot, Policies, under suggestions matching public code.
Scenario With Allow on, Copilot shows a reference to a GPL-licensed repository for a suggestion. What do you do?
Model answer
Stop and think before accepting. If our project can't meet the GPL's terms, I'd reject it and write the code differently, or ask legal. If the licence is permissive, like MIT, I'd keep it and add the attribution it requires.
Architecture & design Which setting would you recommend for a company, and why?
Model answer
Block is the simple default for most companies: matches never appear, so nobody has to judge licences under deadline. Allow suits teams that want the visibility and have clear rules on attribution. Whatever we choose, I'd enforce it at the enterprise level so it's consistent.
Quick revision
Key points
- The policy is "Suggestions matching public code" with values Block and Allow.
- A match is about 150 characters or more of code that matches a public repository.
- Block hides matching suggestions; Allow shows them with code references (repository and licence).
- Inline matches appear in Output › GitHub Copilot Log (Code References); chat lists references in the answer.
- Organization owners set it for org seats; enterprises can enforce it; individuals set it for Free, Pro and Pro+.
- Whatever the setting, the developer is responsible for accepted code.
Important terminology
- Suggestions matching public code
- The Copilot policy with two values, Block and Allow, that controls suggestions matching code in public repositories.
- Block
- The policy value that stops Copilot showing a suggestion that matches public code.
- Allow
- The policy value that shows matching suggestions and adds a code reference so you can see where similar code exists.
- Code reference
- Details Copilot shows for a match with public code, including the repository URL and the licence type.
- Code referencing log
- The "GitHub Copilot Log (Code References)" channel in VS Code's Output panel, where inline suggestion matches are listed.
- Policy enforcement
- An enterprise can set the policy for all its organizations, or leave it to each organization to decide.
Common mistakes
- Thinking Block means Copilot can never produce code like public code. It hides matches it detects.
- Expecting a Business user to change the setting in personal settings.
- Treating a code reference as permission to use the code. You still have to follow the licence.
Exam tips
- "Prevent suggestions that match public code" = set the policy to Block.
- "See the licence of matching code" = Allow plus code references.
- "Where are inline code references in VS Code?" = Output › GitHub Copilot Log (Code References).
- "All organizations must use the same setting" = enforce it at the enterprise.
Five quick revision questions
-
1.What are the two values of the public code policy?Show
Block and Allow.
-
2.About how long is a match?Show
About 150 characters.
-
3.What does a code reference show?Show
The matching repository and its licence.
-
4.Who sets the policy for Copilot Business users?Show
The organization owner, unless the enterprise enforces it.
-
5.Does a code reference mean you can use the code freely?Show
No. You must follow the licence it shows.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Troubleshoot Suggestions and Content Exclusions
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.