AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure GitHub Copilot to Ignore Sensitive Files Across a Repository

Charmaine Ng · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Many development teams adopt GitHub Copilot with enthusiasm, only to hit an immediate security panic: proprietary algorithms, internal API credentials, .env files, and compliance-sensitive directories sit right inside the repository workspace. The immediate instinct is to look for a .copilotignore file—analogous to .gitignore or .dockerignore—drop it in the repository root, and commit.

Here is the inconvenient truth: GitHub Copilot does not natively support a .copilotignore file.

At 365Finds, we see developers repeatedly trip over this misconception. Committing an unauthorized .copilotignore creates dangerous theater: developers assume proprietary code is shielded when Copilot is actually reading every token.

GitHub Copilot does provide repository-wide exclusion, but it does so through an administrative server-side control known as Content Exclusion. For teams operating on GitHub Copilot Business or Copilot Enterprise, this is where repo-level protection actually lives. For individual developers, alternative local workarounds exist.


Method 1: The Official Way — Repository Content Exclusion (Business & Enterprise)

GitHub purposely placed content exclusion into repository and organization settings rather than repository-tracked ignore files. This ensures that individual developers cannot unilaterally modify or bypass IP compliance rules in local branches.

Prerequisites

Step-by-Step Configuration

  1. Navigate to Repository Settings: Open your repository on GitHub.com. Click Settings under the repository name.
  2. Access Copilot Settings: In the left sidebar, navigate to the Code, planning, and automation section. Click Copilot, then select Content exclusion.
  3. Inspect Inherited Rules: If your parent organization or enterprise already enforces exclusion rules, they will appear at the top in read-only gray boxes. Repository-level rules can add further restrictions, but they cannot override or relax inherited enterprise policies.
  4. Define Paths to Exclude: Under Paths to exclude in this repository, enter each target path on a new line using fnmatch pattern syntax. Prefacing rules with a hyphen - and wrapping patterns in quotes is standard:
# Ignore specific sensitive configuration files
- "/config/production.json"
- "/.env.production"
- "/secrets/**"

# Ignore proprietary core algorithms across the repo
- "/src/core/proprietary/**"

# Ignore specific sensitive extensions anywhere in the repository
- "**/*.pem"
- "**/*.key"
- "**/id_rsa*"

# Exclude internal compliance test datasets
- "/test/fixtures/pii/**"
  1. Save Changes: Click Save changes.

How Exclusion Behaves in the Editor

Once saved, policy propagation to developer workstations takes anywhere from immediate synchronization to 30 minutes. To force an immediate update in VS Code:

When a developer opens an excluded file, the Copilot status bar icon displays a diagonal slash or disabled state. Inline completions are halted, Copilot Chat declines to inspect the file buffer as context, and automated Copilot code reviews bypass the file entirely.


Method 2: Local Editor Configuration for Individual Developers

If you are using GitHub Copilot Individual or working in a repository where you lack administrator rights, GitHub's web-based Content Exclusion tab is unavailable.

While you cannot enforce organization-wide policies from your local machine, you can suppress Copilot from triggering inside sensitive files in Visual Studio Code by configuring language-specific settings in .vscode/settings.json:

{
  "files.associations": {
    ".env*": "dotenv",
    "*.key": "plaintext",
    "*.pem": "plaintext"
  },
  "github.copilot.enable": {
    "*": true,
    "dotenv": false,
    "plaintext": false
  }
}

This prevents the inline engine from generating completions when buffers matching those language modes are active.

What About Community .copilotignore Extensions?

You will find third-party extensions in the VS Code Marketplace claiming to reintroduce .copilotignore. These tools operate strictly as local editor automation: they watch active editor tabs and toggle Copilot off when a matching filename is focused.

365Finds strongly advises against relying on these community plugins for organizational security. They provide no backend guarantees, do not affect chat agent context pipelines, and fail silently if a teammate does not install the exact same editor extension.


365Finds Assessment: Guardrail vs. Security Perimeter

365Finds takes a firm stance on this architecture: Content Exclusion is a compliance guardrail, not a cryptographic security perimeter.

Understanding its operational boundaries is critical:

The 365Finds Recommendation

Do not use Content Exclusion as a surrogate for basic secret hygiene. If an active database password, private certificate, or API key lives in plaintext inside your git tree, your security model has already failed.

365Finds recommends reserving GitHub Copilot Content Exclusion for legitimate IP segregation: proprietary trading logic, unpatented algorithms, and regulated PII test fixtures. For raw credentials, keep them strictly out of the repository using secret managers (such as HashiCorp Vault, AWS Secrets Manager, or Doppler) and verify exclusion via local .gitignore and pre-commit secret scanners like Gitleaks.


References