Most developers instinctively look for a .copilotignore file in their repository root the moment sensitive files touch their editor. It does not exist. GitHub has never shipped a native repository-level ignore file for GitHub Copilot.
If you commit API keys, proprietary algorithms, client data schemas, or licensed code you are forbidden from passing to third-party models, you cannot simply add a dotfile to Git and expect GitHub Copilot to look away.
Instead, GitHub routes file exclusions through a centralized management feature called Content Exclusion. It works well, but it comes with enterprise baggage, subscription gates, and quirks that every engineering lead needs to understand before assuming their codebase is shielded.
At 365Finds, we evaluate AI developer tooling from an operational and compliance standpoint. Here is how to configure GitHub Copilot content exclusion correctly, verify that it actually stops data ingestion, and navigate the gaps if you are on an individual plan.
The Catch: Subscription Requirements
Before digging into repository settings, check your license tier.
GitHub Copilot Content Exclusion is available exclusively on GitHub Copilot Business and GitHub Copilot Enterprise.
If you are an individual developer or freelancer paying $10 a month for GitHub Copilot Individual, GitHub gives you no native web interface or repository setting to exclude files. We at 365Finds consider this a frustrating product decision: individual creators handle proprietary client secrets just as often as corporate teams do. If you are on an Individual seat, jump down to the client-side workarounds section below.
If your organization holds a Business or Enterprise contract, exclusions can be managed centrally by organization owners or delegated to repository administrators.
Configuring Content Exclusion in GitHub
Content exclusion rules can be defined at two levels: across an entire GitHub Organization or inside a specific Repository.
Organization-level policies automatically cascade down to every repository owned by the organization. Repository-level rules apply only to that specific codebase.
Step 1: Access the Exclusion Settings
For a Repository
- Navigate to your repository on GitHub.com.
- Click Settings in the top navigation bar.
- In the left sidebar, scroll down to the Code, planning, and automation section.
- Click Copilot, then select Content exclusion.
- Locate the text box labeled Paths to exclude in this repository.
For an Organization
- Go to your organization's main page on GitHub.com.
- Click Settings (under your organization name).
- In the left sidebar, click Copilot, then select Content exclusion.
- In the repository table, add exclusion rules globally across all repositories or select specific target repos.
Step 2: Define File and Directory Patterns
GitHub Copilot content exclusion uses fnmatch pattern syntax. Patterns are evaluated case-insensitively.
You can add comments by beginning a line with #. Each path rule must be placed on its own line:
# Exclude environment and credential stores
*.env*
*.pem
*.key
*.p12
# Exclude specific sensitive credential files at repository root
/config/credentials.json
/config/database.yml
# Exclude entire directories and subtrees
/secrets/**
/vendor/proprietary-sdk/**
/infra/certs/**
# Exclude specific file types across any subfolder
**/*.secret.ts
**/*.private.py
Pattern Matching Rules
| Pattern | Scope | What It Matches |
|---|---|---|
/secrets/** | Directory root | Everything inside the /secrets/ directory and all nested subdirectories |
*.env* | Global pattern | .env, .env.production, .env.local anywhere in the repository |
/config/*.json | Single directory | JSON files in /config/, but not files in /config/subfolder/ |
*.pem | File extension | Any SSL or RSA certificate file across any directory level |
docs/internal-*.md | Relative path | Files matching prefix inside docs/ |
Once you input your patterns, click Save changes.
How Exclusions Behave Across Your Development Stack
When a file matches an exclusion pattern, GitHub Copilot restricts its behavior across several layers:
- Inline Code Suggestions: GitHub Copilot immediately disables inline completions inside the excluded file. The ghost text will not trigger.
- Cross-File Context Ingestion: The contents of the excluded file will not be indexed or injected into the prompt context to inform suggestions in adjacent, non-excluded files.
- Copilot Chat and Copilot Edits: You cannot reference the excluded file using
@fileor#filecommands in the chat panel. If you attempt to prompt Copilot Chat with questions about an excluded file, it returns an explicit error stating the file is excluded by organizational policy. - Copilot Code Review: Automated pull request reviews powered by Copilot skip the flagged paths entirely.
- Copilot CLI: The command-line utility will refuse to read or process inputs originating from excluded paths.
Propagation Delay
Changes do not hit your editor instantaneously. GitHub notes that exclusion policies can take up to 30 minutes to propagate to client IDEs.
If you need immediate enforcement during a sprint or after updating rules, developers must restart their editor or reload the IDE window (Developer: Reload Window in VS Code) to force an immediate policy refresh from GitHub's servers.
How to Verify That Exclusions Are Active in Your Editor
Never assume an exclusion is working until you verify it in the client interface. GitHub Copilot provides a clear visual signal in supported IDEs (VS Code, Visual Studio, and JetBrains IDEs).
In Visual Studio Code:
- Open a file that should be excluded (e.g.,
/secrets/vault.tsor.env.production). - Look at the status bar at the bottom right of the editor window.
- The GitHub Copilot status icon will change from its standard icon to an icon with a diagonal strike-through (
⊘). - Click or hover over the icon. VS Code will display:
GitHub Copilot is disabled for this file because of your organization's content exclusion policy. - Try typing new code. No ghost text suggestions should appear.
If the strike-through icon is absent, check whether the repository remote matches the organization repo on GitHub, ensure you are authenticated with the authorized GitHub account, and reload your window.
What to Do If You Use GitHub Copilot Individual
If you do not have Copilot Business or Enterprise, you cannot use GitHub's web-based Content Exclusion. However, you can prevent accidental code leakage in VS Code through editor-level configuration workarounds.
Workaround 1: Disabling Copilot by Language Association
Visual Studio Code allows you to map file patterns to custom language identifiers and selectively toggle GitHub Copilot off for those identifiers in your project's .vscode/settings.json:
{
"files.associations": {
".env*": "copilot-disabled",
"*.pem": "copilot-disabled",
"secrets.json": "copilot-disabled"
},
"github.copilot.enable": {
"*": true,
"copilot-disabled": false
}
}
This trick reclassifies sensitive files under a dummy language category (copilot-disabled) and turns off completion generation for that specific mode.
Workaround 2: The Community .copilotignore Extension
The VS Code Marketplace includes community extensions such as VSCode Copilot Ignore. These extensions read a local .copilotignore file in your repository root and dynamically toggle the GitHub Copilot extension status whenever your active tab switches to a matching file.
365Finds' Recommendation for Solo Developers
Client-side workarounds are brittle. If you share the repository or clone it on a new laptop, local settings may not carry over unless strictly checked into .vscode/settings.json.
365Finds strongly advises that you never keep unencrypted credentials, sensitive proprietary weights, or client production configs inside your repository workspace in the first place. Use system environment variables, local .gitignore files, and external secret stores such as 1Password CLI, Doppler, or AWS Secrets Manager. What does not exist on disk in the project workspace cannot be ingested by an AI model.
The Real Limitations: What Content Exclusion Cannot Protect
At 365Finds, we look past vendor marketing to assess actual defensive boundaries. Content Exclusion is an administrative guardrail inside GitHub's product ecosystem; it is not an operating system security boundary.
Keep these three fundamental limitations in mind:
1. Semantic Leakage Through Public Interfaces
Excluding /src/security/encryption_engine.py stops Copilot from reading that specific file. However, if /src/api/routes.py is not excluded, and it imports from security.encryption_engine import decrypt_user_vault, AES_KEY_DERIVATION, Copilot will inspect routes.py. It reads your exported function signatures, parameter names, and call patterns. While it cannot see internal proprietary implementations, high-level architecture and nomenclature remain exposed.
2. Autonomous Agent and Shell Execution
Modern agentic workflows (like Copilot agent mode or autonomous terminal tooling) execute shell commands. If an agent runs a raw terminal command like cat /secrets/keys.txt or a build script that dumps configs into terminal output, standard file-level content exclusion does not block the tool execution output unless restricted by shell execution policies.
3. Third-Party Plugins and MCP Servers
If you integrate third-party tools or Model Context Protocol (MCP) servers into your editor, they run outside GitHub's exclusion loop. An MCP filesystem server with broad directory access will read files that GitHub Copilot's native completions have been instructed to ignore.
Enterprise organizations should deploy GitHub Secret Scanning alongside Content Exclusion to catch secrets pushed upstream. Exclude sensitive paths in your GitHub settings, verify the strike-through icon on developer workstations, and treat AI exclusion rules as defense-in-depth rather than your sole line of defense.