GitHub Copilot blocks suggestions that match existing public code to prevent potential license violations. This notification appears when Copilot's duplicate detection filter identifies code that closely resembles code found in public repositories on GitHub.
This message indicates that GitHub Copilot has suppressed a code suggestion because it detected the suggestion matches or closely resembles code that already exists in public GitHub repositories. This is a deliberate safety feature designed to protect you from inadvertently copying licensed code. GitHub Copilot includes a duplicate detection filter that compares generated suggestions against publicly available code on GitHub. When the filter identifies a match of approximately 150 characters or more, it blocks the suggestion from appearing. The filter uses exact string matching, meaning even small variations like different variable names would bypass the filter. This feature exists because Copilot was trained on public code from GitHub repositories, including code under various open-source licenses. Without this filter, Copilot might suggest verbatim code snippets that carry license obligations you may not be aware of. By blocking these matches, GitHub helps you avoid potential legal issues related to code licensing and attribution requirements. The "matches public code" message is informational - it's not an error in your code or a problem with Copilot itself. It simply means Copilot chose not to show you a particular suggestion because that exact code sequence already exists publicly.
GitHub Copilot has a setting that controls whether suggestions matching public code are blocked. By default, this filter is enabled to protect you from license issues.
To check or change this setting in VS Code:
1. Open Settings (Cmd/Ctrl + ,)
2. Search for "copilot"
3. Look for "GitHub Copilot: Enable Auto Completions" and related settings
4. Find the setting related to public code matching
In your GitHub account:
1. Go to [github.com/settings/copilot](https://github.com/settings/copilot)
2. Under Suggestions matching public code, you can choose:
- Block - Suggestions matching public code won't appear (default)
- Allow - Suggestions may include code matching public repositories
Important: Changing this setting to "Allow" means you accept responsibility for checking the license of any suggested code before using it.
When Copilot blocks a suggestion, you can often get a different (unblocked) suggestion by changing your approach:
Add more specific context:
# Instead of generic comment:
# sort the array
# Try more specific context:
# QuickSort implementation for our custom GameScore objects
# using a three-way partition for handling duplicatesUse different variable names:
// Instead of common names like 'arr', 'data', 'result'
// Use domain-specific names that make the code unique
const playerScores = [];
const leaderboardEntries = [];Write partial implementation:
// Start writing your own implementation
function mergeSortedArrays(left: number[], right: number[]): number[] {
const merged: number[] = [];
let leftIndex = 0;
// Copilot will suggest continuation that's more tailored to your code
}The goal is to make your code context unique enough that Copilot generates a distinct suggestion.
When inline suggestions are blocked, Copilot Chat can still help without triggering the same restrictions:
In VS Code with Copilot Chat:
1. Open the Chat panel (Cmd/Ctrl + Shift + I)
2. Ask Copilot to explain the concept or approach
3. Implement based on the explanation rather than copying code
Example prompts that work well:
"Explain how to implement binary search in Python step by step"
"What's the algorithm for merging two sorted lists?"
"Describe the approach for implementing a rate limiter"Then implement yourself:
The explanation gives you the knowledge without providing verbatim code that might be blocked.
Use /explain on your own code:
/explain how this sorting function worksThis approach helps you learn while avoiding any potential licensing concerns.
Before trying to work around blocked suggestions, consider whether using that exact code is the right approach:
Ask yourself:
- Is there a standard library function that does this already?
- Am I reimplementing something that exists in my framework?
- Would a different approach be more appropriate for my use case?
For common algorithms:
# Instead of implementing your own sort:
sorted_list = sorted(my_list, key=lambda x: x.score)
# Instead of writing binary search:
import bisect
index = bisect.bisect_left(sorted_list, target)
# Instead of implementing a hash table:
from collections import defaultdict
cache = defaultdict(list)For frameworks:
// Instead of custom validation logic:
// Use Zod, Joi, or your framework's built-in validation
// Instead of custom state management patterns:
// Use React hooks, Redux, or framework-specific solutionsStandard library and framework code is battle-tested and maintained - often better than reimplementing.
If you understand the licensing implications and want to see blocked suggestions, you can change the setting:
Warning: Enabling this setting means:
- You may receive suggestions that match GPL, LGPL, or other copyleft-licensed code
- You're responsible for verifying the license of suggested code before using it
- Using copyleft code in commercial projects without compliance can lead to legal issues
To allow public code matches:
1. Go to [github.com/settings/copilot](https://github.com/settings/copilot)
2. Find "Suggestions matching public code"
3. Change from Block to Allow
Best practices if you enable this:
- Review the Copilot completion before accepting
- Consider using a license scanning tool like FOSSA, Snyk, or license-checker
- Keep records of where complex algorithms were sourced
- When in doubt, write it yourself or find MIT/Apache-licensed alternatives
For organizations:
Organization admins control this setting at the organization level. If you need it changed, contact your admin.
Copilot can provide multiple suggestions. If one is blocked, try getting alternatives:
In VS Code:
# Keyboard shortcuts for cycling suggestions:
Alt + ] / Option + ] # Next suggestion
Alt + [ / Option + [ # Previous suggestion
Ctrl + Enter # Open completions panel (shows multiple)In other IDEs:
- JetBrains (IntelliJ, PyCharm, etc.): Alt + for next suggestion
- Neovim: Check your Copilot plugin keybindings
- Visual Studio: Alt + . to cycle suggestions
Trigger a fresh suggestion:
1. Delete the current partial code
2. Retype with slightly different wording
3. Add a more specific comment before the code
4. Press Tab again to see if a different suggestion appears
Each suggestion is generated independently, so alternative suggestions may not trigger the same duplicate detection.
When Copilot blocks a suggestion, the underlying code might be a good reference for your implementation:
Search for the public code directly:
1. Go to [github.com/search](https://github.com/search)
2. Search for the function or algorithm name
3. Filter by language and license type
Filter by permissive licenses:
# Search examples on GitHub:
quicksort language:python license:mit
binary search tree language:javascript license:apache-2.0
rate limiter implementation license:bsd-3-clauseLicense-safe sources:
- Official language documentation examples (usually permissive)
- MIT/Apache licensed utility libraries
- Your organization's internal code libraries
- Educational resources with explicit permission to use
If you find the original code:
1. Check the repository's LICENSE file
2. Understand the obligations (attribution, share-alike, etc.)
3. Comply with the license requirements
4. Document the source in your codebase if required
### How the Duplicate Detection Filter Works
GitHub Copilot's duplicate detection compares suggestions against a reference database of public code. Key technical details:
- Match threshold: Approximately 150 characters of exact match triggers blocking
- Matching algorithm: Uses exact string comparison (not semantic similarity)
- Database: Includes code from public GitHub repositories
- Filter timing: Applied after suggestion generation, before display
This means that:
- Changing variable names often bypasses the filter
- Adding comments or whitespace can affect matching
- Semantic equivalence doesn't trigger blocking (different code that does the same thing)
### Enterprise and Organization Settings
If you're using GitHub Copilot Business or Enterprise:
- Organization owners can set policies for all users
- Settings at [github.com/organizations/YOUR_ORG/settings/copilot](https://github.com/organizations/YOUR_ORG/settings/copilot)
- Individual settings may be overridden by organization policy
- Policy can be set to "No Policy" (user choice), "Allow", or "Block"
Check with your organization admin if you can't change this setting.
### License Scanning Integration
For teams concerned about licensing, consider integrating these tools:
# Example GitHub Actions workflow for license scanning
name: License Check
on: [push, pull_request]
jobs:
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: FOSSA Scan
uses: fossa-contrib/fossa-action@v3
with:
api-key: ${{ secrets.FOSSA_API_KEY }}### When Blocking Is Frequent
If you frequently see blocked suggestions:
1. You might be working on common patterns - Standard algorithms naturally match public code
2. Your code style may be generic - Add project-specific naming conventions
3. Consider the educational value - Writing it yourself builds understanding
### Copilot's Training and Code Provenance
Copilot was trained on public GitHub repositories. The model learns patterns, not specific code, but can sometimes reproduce training data verbatim (especially for popular, frequently-seen code).
The duplicate detection filter exists because:
- Training included code under various licenses (MIT, GPL, LGPL, Apache, proprietary, etc.)
- Verbatim reproduction could carry license obligations
- GitHub wants to help users avoid inadvertent license violations
### Alternative AI Coding Assistants
If the public code filter is problematic for your use case, alternatives exist with different approaches:
- Amazon CodeWhisperer - Similar filter with reference tracking feature that shows original source
- Tabnine - Offers private model options trained only on permissive code
- Sourcegraph Cody - Can be configured with specific code sources
Each has different tradeoffs for code provenance and licensing.
### Debugging Copilot Issues
If suggestions are blocked unexpectedly:
# Check Copilot extension logs in VS Code:
# 1. Open Output panel (View > Output)
# 2. Select "GitHub Copilot" from dropdown
# 3. Look for "filtered" or "blocked" messages
# Check your settings are applied:
# 1. Open Command Palette (Cmd/Ctrl + Shift + P)
# 2. Run "GitHub Copilot: Open Logs"warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server