AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How GitHub Copilot Blocks Public Code in Private Repositories

Lara Jorge Ricart · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Writing closed-source software inside a private repository does not insulate you from copyright exposure. When GitHub Copilot generates code, it draws on probabilistic patterns learned from public software. Left unchecked, it can spit out verbatim blocks of copyleft-licensed code directly into your proprietary codebase.

At 365Finds, we evaluate AI developer tools through both developer throughput and enterprise legal risk. If your proprietary software accidentally incorporates code covered under the GNU General Public License (GPL) or Affero GPL (AGPL), your commercial distribution model faces severe legal headaches. GitHub Copilot tackles this through an automated gatekeeper: the Suggestions matching public code filter.

Here is how the detection mechanism works, what it does and does not protect, and how to configure it across individual, organization, and enterprise accounts.


How the Public Code Filter Works

GitHub Copilot does not publish or leak your private repository code when you use the filter. Your private prompts and editor context remain private.

Instead, the filtering mechanism operates on Copilot's proposed output before that output ever touches your screen:

  1. Generation: When you pause typing, GitHub Copilot constructs a candidate suggestion based on your editor context.
  2. Context Window Check: Copilot takes the candidate code snippet along with roughly 150 characters of surrounding code context.
  3. Index Comparison: It runs this snippet against an index of public code repositories hosted on GitHub.com.
  4. Action Determination:
    • If set to Block: Any suggestion that matches or near-matches indexed public code is suppressed immediately. The IDE behaves as if no completion was generated.
    • If set to Allow: Copilot serves the suggestion. If the match is identical to public repositories, Copilot surfaces Code Referencing in supported IDEs (VS Code, Visual Studio, JetBrains), displaying matching repository URLs, owners, and identified software licenses (e.g., MIT, Apache 2.0, GPL, or NOASSERTION).
[Local Private Repo Context] 
             ↓
[Copilot Inference Model] 
             ↓
[Candidate Suggestion (~150 chars context)] 
             ↓
[GitHub Public Code Match Index]
      ↙                     ↘
[Match Detected?]       [No Match]
   ↙            ↘              ↓
Block Mode   Allow Mode   [Deliver Suggestion]
   ↓            ↓
[Suppress]   [Deliver + Code Reference Log]

365Finds Assessment: Block vs. Allow

Our verdict at 365Finds is unambiguous: enforce "Block" across all commercial private repositories.

Some teams toy with the "Allow" setting because they like the idea of inspecting code references. In practice, that is an illusion. Developers working under sprint deadlines do not stop to read open-source license terms or trace whether an accepted 4-line helper function originated from a GPL-3.0 repo. They press Tab and move on.

Allowing public code matches with referencing turns every developer into an untrained copyright clearance officer. Unless your organization maintains a dedicated IP review team auditing Copilot reference logs in real time, "Allow" is an unmanaged liability.

Where the Filter Falls Short

You must understand the technical boundaries. 365Finds does not treat this filter as an impenetrable legal firewall:

The filter eliminates accidental, verbatim copying of large blocks. It does not replace code scanning tools like Black Duck, Snyk Open Source, or GitHub Advanced Security.


Step-by-Step Setup Guide

Configuration permissions follow GitHub's standard governance hierarchy: Enterprise > Organization > Individual. A restrictive policy enforced at an upper level cannot be relaxed at a lower level.

1. Enterprise Accounts (GitHub Enterprise Cloud)

Enterprise administrators set the baseline for all organizations under their umbrella.

  1. Navigate to your enterprise account on GitHub: https://github.com/enterprises/{your-enterprise}.
  2. In the enterprise sidebar, click Policies, then select Copilot.
  3. Under Policies, locate Suggestions matching public code.
  4. In the dropdown menu, select Blocked.
  5. Set the enforcement level to No policy if you want individual organizations to decide, or choose Blocked globally to prevent organization owners from overriding the restriction.

2. Organization Accounts (GitHub Team / Copilot Business / Enterprise Org)

If your enterprise delegates policy or if you manage a standalone GitHub organization:

  1. Go to your organization homepage: https://github.com/organizations/{your-org}/settings.
  2. In the left navigation menu, scroll down to the Code, planning, and automation section and click Copilot > Policies (or Policies under Copilot).
  3. Find the section labeled Suggestions matching public code.
  4. Click the dropdown and select Blocked.
  5. Click Save to confirm.

Once enabled, every seat assigned under this organization inherits the block rule immediately. Individual developers cannot enable matching suggestions in their personal editors for corporate work.

3. Individual Subscribers (Copilot Pro / Copilot Individual)

If you are a solo developer or freelancer using Copilot on private client repositories:

  1. Click your profile photo in the top-right corner of GitHub and select Settings.
  2. In the left sidebar under Access, click Copilot (or Your Copilot).
  3. Under Policies and features, locate Suggestions matching public code.
  4. Select Block from the dropdown menu.
  5. Click Save.

Verifying Policy Enforcement in the IDE

After setting the policy to Block, developers do not need to configure anything inside Visual Studio Code, JetBrains IDEs, or Neovim. The language server fetches policy metadata during authentication.

To verify enforcement in VS Code:

  1. Open the Output panel (Ctrl+Shift+U or Cmd+Shift+U).
  2. Select GitHub Copilot from the dropdown channel list.
  3. Trigger completions. You will see filter evaluations logged internally whenever public code matches are intercepted, confirming that candidate suggestions are dropped prior to editor rendering.

References