If you expect a simple .copilotignore file to drop into your Git root, prepare for disappointment. GitHub Copilot has never provided one.
Keeping proprietary algorithms, cryptographic keys, and local environment secrets out of GitHub Copilot’s context window is a primary concern for any engineering team adopting AI. Yet the platform treats exclusion as an administrative governance feature rather than a developer configuration file. At 365Finds, we find this design choice understandable for enterprise compliance, but frustrating for individual developers.
Depending on your subscription tier, your exclusion strategy looks completely different. Here is how to configure content exclusions properly, where the boundaries hold, and where they break down.
1. Repository-Level Exclusion (Business & Enterprise Plans)
If your repository belongs to an organization with GitHub Copilot Business or GitHub Copilot Enterprise, repository administrators can enforce exclusion rules directly in the repository settings.
Configuration Steps
- Open your repository on GitHub.
- Click Settings in the top navigation bar.
- In the left sidebar, navigate to Copilot > Content exclusion.
- In the text area labeled Paths to exclude in this repository, enter your patterns using YAML list syntax.
- Click Save changes.
# Block a specific proprietary directory
- "/src/proprietary/**"
# Block secret configuration files anywhere in the repo
- "**/.env"
- "**/*.pem"
- "**/secrets.json"
# Block entire build artifact or data folders
- "/data/**"
- "*.pfx"
Path Syntax Rules
GitHub Copilot relies on Ruby's fnmatch pattern matching, case-insensitive. Remember these quirks:
- Each entry must be a YAML list item starting with
-and wrapped in double quotes"". /path/**matches all files and subdirectories under/path/.**/.envmatches.envin the repository root and every nested directory.- A path without a leading slash like
"secrets.json"matches only in the root or must be prefixed with**/to match recursively.
When configured, the Copilot status icon in supported IDEs (VS Code, JetBrains, Visual Studio) displays a diagonal strike-through icon whenever an excluded file is active.
2. Organization-Level Exclusion (Fleet-Wide Rules)
Managing exclusion file by file across dozens of repositories is impractical. Organization owners can apply rules globally across all repositories or target specific repositories using YAML mappings.
Configuration Steps
- Navigate to your Organization page on GitHub.
- Click Settings > Copilot > Content exclusion.
- Define repository targets and exclusion paths in YAML format:
# Apply globally across all repositories in the organization
"*":
- "**/.env*"
- "**/*.key"
- "**/credentials.json"
- "/internal-security/**"
# Target specific sensitive repositories with tighter boundaries
"payment-gateway-service":
- "src/pci-vault/**"
- "certs/**"
- Save the configuration. Changes propagate to developer IDEs within roughly 30 minutes, or upon restarting the editor.
3. The Individual & Pro Dilemma: Client-Side Mitigation
If you are paying for GitHub Copilot Individual or using a personal account, GitHub offers zero server-side content exclusion settings. Repository and organization content exclusions are locked behind Business and Enterprise licenses.
At 365Finds, we consider this gatekeeping a real security hazard for solo developers and open-source contributors. If you are on an Individual tier, your only protection is client-side configuration in your editor.
In VS Code: Disable Copilot for Sensitive Language Modes
You can map sensitive file extensions to distinct language identifiers and disable Copilot completion for those modes in your user or workspace .vscode/settings.json:
{
"files.associations": {
".env*": "dotenv",
"*.key": "plaintext",
"*.pem": "plaintext"
},
"github.copilot.enable": {
"*": true,
"dotenv": false,
"plaintext": false
}
}
Disable Copilot for Entire Workspaces
For projects dealing with sensitive customer data, disable the extension entirely for that workspace via .vscode/settings.json:
{
"extensions.disabled": [
"GitHub.copilot",
"GitHub.copilot-chat"
]
}
This prevents inline code suggestions. However, it does not guarantee that adjacent active editor tabs won't leak semantic references to remote models if you interact with Copilot Chat.
What Content Exclusion Actually Guarantees (And What It Doesn't)
Understanding the technical perimeter of content exclusion prevents false security assumptions:
| Protected Surface | Behavior Under Exclusion |
|---|---|
| Inline Completions | Blocked entirely inside excluded files. |
| Context Window Leakage | Excluded file content is not sent as prompt context to inform completions in other files. |
| Standard Copilot Chat | Chat ignores excluded files when indexing workspace references. |
| Copilot Pull Request Reviews | Excluded files are bypassed during automated reviews. |
| Symbol & Type Definitions | Partially exposed if non-excluded files import or reference exported symbols from excluded files. |
| Agent / Terminal Execution | Third-party agent modes or external tool-call runners may bypass client-side guardrails. |
Content exclusion is a policy guardrail for GitHub-controlled client extensions. It is not an operating system sandbox or an encryption barrier.
365Finds recommends treating content exclusion as secondary defense-in-depth. Real credentials must never live in tracked files in the first place—use external secrets managers like 1Password CLI, AWS Secrets Manager, or HashiCorp Vault, and keep .env in your .gitignore.