Developers looking for a .copilotignore file in their repository root will quickly discover a frustrating reality: GitHub Copilot does not have a native, in-repo ignore file. Putting a .copilotignore next to your .gitignore does nothing out of the box.
GitHub manages file exclusions server-side through a feature called Content Exclusion, gated behind GitHub Copilot Business and Enterprise subscriptions. If you need to stop GitHub Copilot from slurping proprietary business logic, .env files, or entire private repositories into its inference window, you have to configure it either through organization policies, repository settings, or local editor overrides.
At 365Finds, we believe GitHub's decision to withhold native file-based exclusions from individual developers and lock centralized exclusion behind higher-tier enterprise seats is an unnecessary operational hurdle. Here is exactly how content exclusion works, how to configure it across repositories, and where its actual protection boundaries end.
1. The Myth of .copilotignore
Many engineering teams assume GitHub Copilot mirrors Git conventions with an ignore file committed to version control. It does not.
There are unofficial third-party VS Code extensions (such as copilotignore-vscode) that parse a local .copilotignore and attempt to toggle the Copilot extension status whenever an active editor tab matches an ignored pattern. At 365Finds, we explicitly advise against relying on these community extensions for enterprise security. They operate strictly on the client side, depend on client focus events, break during background tool indexing, and cannot be centrally audited or enforced across a distributed development team.
If you are on an official GitHub Copilot Business or Enterprise tier, you must use GitHub's native Content Exclusion.
2. Exclude Files at the Repository Level
Repository administrators can exclude specific files, directories, or file extensions directly from the repository's settings on GitHub.
Step-by-Step Configuration:
- Navigate to your repository on GitHub.
- Select Settings in the top navigation bar.
- In the left sidebar, navigate to Code, planning, and automation > Copilot > Content exclusion.
- In the Paths to exclude in this repository editor, enter the target paths using
fnmatchglob syntax. Each path must be formatted as a YAML list item (- "path"). - Click Save changes.
# Block specific secret files
- ".env"
- ".env.*"
- "config/master.key"
# Block an entire directory of proprietary algorithms
- "src/proprietary/**"
- "internal/core-engine/**"
# Block specific file extensions across all subdirectories
- "**/*.pem"
- "**/*.key"
- "**/*.cert"
What Happens Once Saved:
- Inline Suggestions: Copilot disables code completions inside any matching file.
- Contextual Suggestions: Excluded files will never be pulled into the context window to assist suggestions in other, non-excluded files.
- Copilot Chat: Chat queries cannot reference excluded files, and Copilot will refuse to summarize or inspect them.
- Copilot Code Review: Excluded files are omitted from automated AI code reviews.
- IDE Visual Indicator: In VS Code, JetBrains IDEs, and Visual Studio, opening an excluded file will show the GitHub Copilot icon in the status bar struck through with a diagonal line.
Note: Changes can take up to 30 minutes to propagate to active IDE instances. Restarting the editor or reloading the Copilot language server accelerates the sync.
3. Exclude Files and Entire Repositories at the Organization Level
For engineering leaders managing dozens or hundreds of microservices, configuring exclusions repo-by-repo is impractical. Organization and Enterprise administrators can configure global exclusion schemas that cascade down to all managed repositories.
Step-by-Step Organization Setup:
- In the top right corner of GitHub, click your profile picture and select Your organizations.
- Select your organization and click Settings.
- In the left sidebar, click Copilot > Content exclusion.
- Enter your exclusion rules in the YAML configuration box.
Exclude Across All Repositories:
Use the wildcard "*" repository key to apply file path blocks across every repository owned by the organization:
"*":
- "**/.env"
- "**/.env.*"
- "**/secrets/**"
- "**/*.pem"
- "**/*.pfx"
Exclude an Entire Private Repository:
To completely blind GitHub Copilot to a specific private repository, target the repository's HTTPS URL and block all files using "**":
"https://github.com/your-org/highly-confidential-algo":
- "**"
When an entire repository is matched by "**", Copilot shuts down completely within that workspace. Any exclusions defined at the enterprise or organization level will appear as grayed-out, read-only entries in the repository-level settings, preventing individual repository admins from overriding them.
4. Local Workarounds for Copilot Individual Subscribers
GitHub does not provide the Content Exclusion dashboard for Copilot Individual subscribers ($10/month). If you are a solo contractor or small team without an organization plan, your options are limited to editor-level language toggles.
In Visual Studio Code, open your settings.json (either User or Workspace level) and disable Copilot for specific languages or file associations:
{
"files.associations": {
".env*": "dotenv",
"*.secret": "plaintext"
},
"github.copilot.enable": {
"*": true,
"dotenv": false,
"plaintext": false,
"yaml": false
}
}
This prevents inline completions when a file with that language identifier is focused. However, 365Finds emphasizes: this does not provide cryptographic or context isolation. If Copilot Chat or agentic indexing scans the workspace directory, language toggles in settings.json do not guarantee workspace-wide context exclusion.
5. Security Realities: What Content Exclusion Does Not Do
365Finds cautions every engineering organization: Content exclusion is a prompting filter, not an access control boundary.
- Secrets Do Not Belong in Code: If an API secret or database credential is committed to git, adding it to Content Exclusion does not secure it. It only asks Copilot not to read it. Secrets belong in credential vaults (such as HashiCorp Vault, AWS Secrets Manager, or Doppler) or environment injection pipelines, not plaintext files.
- Indirect Semantic Leakage: If
secrets_handler.pyis excluded, butpayment_service.pyimports functions, classes, and parameter names from it, Copilot still readspayment_service.py. It can infer function signatures, business architecture, and parameter schemas from downstream references. - Symlinks and External Mounts: GitHub's documentation explicitly notes that Content Exclusion does not apply to symbolic links or files located on remote network filesystems.
Enterprise exclusion policies prevent casual leakage of proprietary modules into AI prompt contexts, but genuine IP and credential security requires strict repository permissions, automated secret scanners, and zero-trust credential architectures.