Learn to configure content exclusion in GitHub Copilot to protect sensitive data by ignoring specific files or directories.
Learn how to configure content exclusion in GitHub Copilot to safeguard sensitive data. By specifying files or directories to ignore, you can prevent accidental exposure of proprietary code, customer data, and credentials.Content exclusion offers three key benefits:
No code completions in excluded files
Excluded content has zero influence on suggestions in other files
Exclude sensitive directories or files within a single repository:
Navigate to Settings → Copilot → Content Exclusion.
Add fnmatch patterns (wildcards supported).
Click Save to apply immediately.
Example: Exclude a config/ directory and its contents.
Copy
Ask AI
# Patterns in the repository-level settingsconfig/***.secret.js
Copy
Ask AI
// src/App.jsimport { useState } from 'react';// This file is processed by Copilot since it's not excluded.function App() { const [image, setImage] = useState(null); // ... return <div>App Component</div>;}
Use fnmatch patterns to fine-tune exclusions. For details, see the fnmatch documentation.
Mastering content exclusion is essential for GitHub Copilot certification. It demonstrates best practices for balancing productivity with security in modern development workflows.