Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 29 of 30
❮Prev Next❯

Public Code Matching in Copilot: Block or Show References

Module 6: Privacy & Safeguards ⏱ 9 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    VS Code & GitHub: Suggestions matching public code Set the public code policy and read a code reference.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading…

    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
    1. 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.
    2. With Block, the matching suggestion simply isn’t shown.
    3. 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.

    😟 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
    🛠️ Solved with: Public code filter

    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

    BlockAllow
    Matching suggestion shown?NoYes
    Code reference?—Yes: repository URL and licence
    WhereSuggestion simply doesn’t appearInline: Output › GitHub Copilot Log (Code References). Chat: listed in the answer
    Good forTeams that want no licence decisions at the keyboardTeams 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

    PlanWho controls the settingWhere
    Copilot Free, Pro, Pro+YouYour personal Copilot settings on github.com
    Copilot BusinessOrganization ownerOrganization settings › Copilot › Policies
    Copilot EnterpriseEnterprise owner (enforce) or each organizationEnterprise 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

    Online retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    Your organization uses GitHub Copilot Business. You must ensure that developers never see Copilot suggestions that match code in public repositories. What should you configure?

    Question 2

    Question 2 of 5

    Developers want to see the license of public code that matches a Copilot suggestion so that they can decide whether to use it. Which configuration meets the requirement?

    Question 3

    Question 3 of 5

    The public code policy is set to Allow. A developer accepts an inline suggestion in Visual Studio Code that matches public code. Where can the developer view the code reference details?

    Question 4

    Question 4 of 5 · Select 2

    Which TWO statements about the Suggestions matching public code setting are true? Each correct answer presents a complete solution.

    Question 5

    Question 5 of 5

    An enterprise has 12 organizations. Security policy requires that all organizations block suggestions matching public code, and organization owners must not be able to change the setting. What should the enterprise owner do?

    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. 1.What are the two values of the public code policy?Show

      Block and Allow.

    2. 2.About how long is a match?Show

      About 150 characters.

    3. 3.What does a code reference show?Show

      The matching repository and its licence.

    4. 4.Who sets the policy for Copilot Business users?Show

      The organization owner, unless the enterprise enforces it.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.