If you are managing sensitive proprietary algorithms, private certificates, or compliance-restricted repositories, you do not want an AI assistant reading those buffers into prompt context. 365Finds tested and evaluated the administrative and local methods to block GitHub Copilot, and the short answer is straightforward: the official mechanism is Content Exclusion.
The critical commercial reality is that GitHub locks native Content Exclusion behind GitHub Copilot Business ($19 per user/month) and GitHub Copilot Enterprise ($39 per user/month). If you run GitHub Copilot Individual ($10 per month), GitHub gives you no native web repository settings to block file paths. You have to rely on local editor workarounds.
At 365Finds, our stance is clear: Content Exclusion is a valuable compliance guardrail, but it is not a cryptographic vault. You should use it systematically across your organization, while understanding exactly what it does, how to configure it at every level, and where its protective boundaries end.
What Happens When You Exclude Content
When a file or repository matches an active exclusion rule:
- Inline Code Completion Disables Instantly: The Copilot extension stops generating suggestions when your cursor is inside that file.
- Context Bleed Stops: The excluded file will not be indexed or injected as neighboring context to inform completions in other open editor tabs.
- Chat and Agent Restrictions: Copilot Chat (
@workspaceor inline chat) refuses to read or process the contents of excluded paths. - Pull Request Code Reviews Skip It: GitHub Copilot code reviews will ignore the restricted files.
In editors like Visual Studio Code, the GitHub Copilot status bar icon shows a distinct diagonal slash when an excluded file is open. Hovering over the icon displays a tooltip confirming that completions are disabled by content exclusion policies.
Method 1: Exclude Paths or Entire Repositories at the Repository Level
If you are a repository administrator (and your organization has a Copilot Business or Enterprise subscription), you can configure exclusions directly inside the repository.
Step-by-Step Configuration
- Open your repository on GitHub.com.
- Click Settings in the top navigation tab.
- In the left sidebar under Code, planning, and automation, click Copilot, then click Content exclusion.
- In the Paths to exclude in this repository text box, enter your path patterns using YAML list syntax.
- Click Save.
Path Syntax and Examples
Each rule must be enclosed in quotation marks and preceded by a hyphen (-). Rules use fnmatch wildcard syntax and are case-insensitive. You can prefix lines with # for comments.
# Exclude the entire repository from Copilot completion
- "/**"
# Exclude sensitive directories
- "/secrets/**"
- "/internal/crypto/**"
# Exclude specific files anywhere in the repo
- "*.env"
- "secrets.json"
- "credentials.yml"
# Exclude specific file types
- "*.pem"
- "*.key"
To shut down GitHub Copilot across an entire repository without disabling the seat for the developer, adding - "/**" or - "*" at the repository root is the cleanest, fastest method.
Method 2: Enforce Exclusions Across an Entire Organization or Enterprise
Managing exclusions repo by repo is fragile. Organization owners and enterprise administrators should set blanket policies centrally.
Organization-Level Setup
- Go to your organization page on GitHub.com and click Settings.
- In the left sidebar, select Copilot > Content exclusion.
- Under Repositories and paths to exclude, define your rules.
At the organization level, you can target specific repositories using their clone URL, or apply global file rules across every repository in the organization using the *: prefix:
# Block an entire sensitive repository by repository reference
https://github.com/your-org/payments-core.git:
- "**"
# Block specific subdirectories inside another repository
git@github.com:your-org/analytics-service.git:
- "/config/production/**"
- "/keys/**"
# Universal block across all organization repositories (Git and non-Git)
*:
- "*.env"
- "*.pem"
- "id_rsa*"
- "/deploy/credentials.json"
Enterprise Inheritance
If your enterprise administrator configures rules under Enterprise AI controls > Copilot > Content exclusion, those rules become mandatory baselines. Organization and repository settings display enterprise-enforced paths in gray, locked boxes. Lower-level admins cannot remove or override them.
Propagation Timing: Don't Panic When It Takes Minutes
Changes saved on GitHub.com do not apply immediately to active IDE sessions. GitHub caches policies locally in editor extensions.
- Normal background synchronization takes up to 30 minutes.
- To force an immediate update in Visual Studio Code, open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) and run:Developer: Reload Window - In JetBrains IDEs or Visual Studio, restart the editor completely.
Once reloaded, opening any excluded file will immediately trigger the crossed-out Copilot icon in the status bar.
The Copilot Individual Workaround (Local VS Code Settings)
What if your company uses GitHub Copilot Individual ($10/user) where Content Exclusion is unavailable?
There is no native .copilotignore file supported out-of-the-box by GitHub. However, you can prevent inline completions locally in VS Code by disabling the extension for sensitive language types or filenames in .vscode/settings.json:
{
"files.associations": {
".env*": "dotenv",
"*.secret": "plaintext"
},
"github.copilot.enable": {
"*": true,
"dotenv": false,
"plaintext": false
}
}
365Finds does not recommend this as an enterprise security policy. Any developer can delete their local .vscode folder or change language associations back to Python or TypeScript, instantly reactivating Copilot. Treat this purely as personal friction against accidental leakage, not organizational governance.
The Boundaries: What Content Exclusion Does NOT Protect
365Finds advises engineering teams to maintain realistic expectations regarding Copilot Content Exclusion:
| Protection Dimension | Content Exclusion Capability | Engineering Reality |
|---|---|---|
| Inline suggestions in file | Blocked completely | Effective guardrail against accidental autocompletes |
| Neighboring file prompt injection | Excluded files are omitted from prompt context | Effective; prevents open tabs from leaking code |
| Copilot Chat context | Blocked from reading excluded paths | Works for official @workspace and chat tools |
| Type and symbol inference | Partial leak possible | If unexcluded files import exported types, Copilot infers shapes |
| Hardcoded secrets protection | NOT a security boundary | Secrets must live in a vault, never in the repository |
| Non-GitHub AI tools & CLI scripts | Ineffective | Third-party MCP tools and external scripts ignore GitHub policies |
If a database password or private signing key is sitting in an excluded file in cleartext, that credential is fundamentally unmanaged. Content Exclusion keeps the buffer out of GitHub Copilot's prompt window, but it does not sanitize your git history or protect against malicious extensions.
365Finds recommends using Content Exclusion as layer two of a three-layer defense: automated secret scanning (like Gitleaks or GitHub Secret Scanning) at commit time, centralized credential vaults for production keys, and repository-wide - "/**" exclusions on proprietary or highly regulated codebases.