You can stop GitHub Copilot from reading or autocompleting sensitive code, but only if you hold the right license and configure exclusions in the right place. GitHub provides a native Content Exclusion engine that blocks Copilot from indexing files, suggesting completions inside them, or sending their contents into prompt contexts.
However, there is an immediate catch that frustrates individual developers: native, server-enforced content exclusion is strictly reserved for Copilot Business and Copilot Enterprise organizations. If you are on Copilot Individual, you are forced to manage exclusions locally inside your editor.
At 365Finds, we have audited how teams implement these policies. Here is the operational playbook for repository administrators, organization owners, and solo developers, along with where this safeguard falls short.
1. Excluding Files in a Specific Repository (Admin)
If your repository belongs to an organization with Copilot Business or Enterprise, repository administrators can set exclusion rules directly in the repository settings.
Step-by-Step Configuration:
- Navigate to the main page of your repository on GitHub.
- Click Settings in the top navigation bar.
- In the left sidebar, under Code, planning, and automation, select Copilot, then click Content exclusion.
- In the text area labeled Paths to exclude in this repository, enter each exclusion pattern on a new line.
- Click Save (or Save changes).
Path Syntax and fnmatch Pattern Rules:
GitHub uses fnmatch pattern matching (case-insensitive). Every path relative to the root of the repository must begin with a forward slash (/).
# Exclude a specific sensitive configuration file
/config/production.json
# Exclude an entire directory and all subdirectories
/certs/**
/internal-tools/**
# Exclude specific file types anywhere in the repository
*.pem
*.key
*.env*
# Exclude a specific file by name anywhere in the repo
**/credentials.xml
Note on inheritance: If your parent organization or enterprise has already declared global exclusions, those rules will appear at the top in gray boxes. You cannot override, weaken, or delete higher-level exclusions from inside a single repository.
2. Excluding Entire Repositories or Multi-Repo Paths (Org & Enterprise)
Managing exclusion file by file across dozens of microservices is unsustainable. Organization owners and Enterprise administrators can enforce global bans across multiple repositories simultaneously.
Where to Configure:
- Organization Level: Go to your Organization page ➔ Settings ➔ left sidebar Copilot ➔ Content exclusion.
- Enterprise Level: Go to your Enterprise account ➔ Policies ➔ Copilot ➔ Content exclusions.
Configuration Format:
In the organization settings box, reference the repository name followed by the targeted path list:
# Completely exclude an entire repository from GitHub Copilot
owner/internal-proprietary-core:
- "/**/*"
# Exclude sensitive folders in a specific repository
owner/payment-gateway:
- "/vault/**"
- "/src/legacy-crypto/**"
# Exclude files across another repository
owner/auth-service:
- "/secrets/*"
Applying "/**/*" tells the GitHub Copilot backend that the designated repository is a black box. No inline suggestions will ever trigger inside it, and no code from it will be transmitted to Copilot servers to assist other repositories.
3. What Happens in the Editor (And the Propagation Delay)
Once a file is excluded, the behavior across supported IDEs (Visual Studio Code, JetBrains IDEs, Visual Studio, and Xcode) changes immediately:
- Suppressed Completions: The moment an engineer opens an excluded file, GitHub Copilot's status bar icon indicates that suggestions are disabled (often displaying a slash or inactive status). Ghost text autocompletions will not appear.
- Context Window Shielding: The contents of that open file will not be included in the context payload sent to Copilot when writing code in neighboring open tabs.
- Chat and Code Review Block: Copilot Chat will refuse to summarize, analyze, or generate tests using the content of excluded files.
The Propagation Reality
Do not expect instant synchronization across your team's machines. Policy updates on GitHub.com can take up to 30 minutes to propagate through GitHub's policy servers to active IDE client sessions.
If an engineer needs the rule applied immediately, they must reload their editor window (in VS Code: Ctrl+Shift+P / Cmd+Shift+P ➔ Developer: Reload Window) or sign out and back into their GitHub account in the editor.
4. The Individual Plan Dilemma: Client-Side Workarounds
GitHub does not offer the web-based Content Exclusion dashboard to Copilot Individual accounts. 365Finds considers this a glaring gap in GitHub's safety tiering. Solo developers and contractors handling proprietary client code need protection just as much as enterprises.
If you are on Copilot Individual, you have two local mitigation options inside VS Code:
Option A: Disable Copilot for Specific Languages and File Types
You can configure VS Code's settings.json (or .vscode/settings.json within your workspace) to turn off Copilot for custom file associations:
{
"files.associations": {
".env*": "dotenv",
"*.key": "plaintext"
},
"github.copilot.enable": {
"*": true,
"dotenv": false,
"plaintext": false,
"yaml": false
}
}
Option B: Disable Copilot Completely for a Workspace
When working on a sensitive repository where you want zero Copilot activity:
- Open the project root in VS Code.
- Open the Extensions sidebar (
Ctrl+Shift+XorCmd+Shift+X). - Find GitHub Copilot, click the gear icon, and select Disable (Workspace).
- VS Code creates a local workspace configuration that leaves Copilot running for your personal open-source projects while silencing it completely inside that client directory.
5. 365Finds Commercial Judgment: Guardrail vs. Security Perimeter
365Finds recommends implementing Content Exclusion across all corporate repositories containing proprietary trade secrets or sensitive schema configurations. The friction for developers is zero, and the policy enforcement is centralized.
However, we must issue a blunt warning: Content exclusion is a policy guardrail, not an encryption boundary or a security perimeter.
Many engineering leads make the dangerous mistake of assuming that adding .env or /keys/ to Copilot Content Exclusion makes it safe to keep raw credentials in Git. It does not:
- Git history remains exposed: If a secret is committed to Git, every developer, CI/CD runner, and compromised developer machine already has read access. Content exclusion only stops Copilot from generating suggestions based on that file; it does not protect the file from human or automated exfiltration.
- Indirect semantic leaks: Copilot still reads surrounding code. If an unexcluded file imports a type or calls a descriptive helper function from an excluded file, Copilot can deduce data structures and business logic from the surrounding context.
- Autonomous agent exceptions: In advanced agentic workflows where Copilot Chat or command-line agents are granted local terminal execution permissions, running shell tools like
grep,cat, or build scripts can expose contents regardless of editor-level completion filters.
Our firm stance at 365Finds is that Content Exclusion should always be the second layer of defense, never the first. Real secrets belong in a dedicated secret store (such as HashiCorp Vault, Doppler, or AWS Secrets Manager) and in .gitignore. Use Copilot Content Exclusion to protect proprietary algorithms, competitive intellectual property, and internal frameworks from model indexing.