GitHub Copilot is a powerful AI coding assistant and I couldn't miss it anymore. But there are times when you need to prevent it from accessing certain files or directories. Whether it's sensitive configuration files, proprietary code, or files that would add unnecessary noise to suggestions, exclusions help you maintain control over what Copilot sees.
Why exclude content?
You might want to exclude content from Copilot for several reasons:
- Security and privacy: Keep API keys, passwords, and other secrets away from AI processing
- Proprietary code: Protect sensitive business logic or algorithms
- Noise reduction: Exclude generated files, dependencies, or build artifacts that don't help with suggestions
- Performance: Reduce the context window size for faster suggestions
Reasons enough to spend some time configuring your content exclusions.
GitHub Copilot content exclusion settings
Content exclusion is a Copilot Business or Enterprise feature and can be configured at either repository-level or organization-level.
Repository-level exclusion
- Navigate to your repository on GitHub
- Go to Settings → Copilot
- Add path patterns to exclude
Organization-level exclusion
Organization admins can set policies that apply across all repositories:
- Go to your organization settings on GitHub
- Navigate to Copilot settings
- Configure content exclusion policies
These settings use glob patterns like:
**/secrets/**- Exclude all secrets directories*.config- Exclude all config filessrc/internal/**- Exclude internal source code
Sidenote: .aiignore file
The Jetbrains AI assistant supports the concept of an .aiignore file, similar to a .gitignore file.
I hope that we’ll see the same idea appear in VSCode when using Github Copilot.
More information
Content exclusion for GitHub Copilot - GitHub Docs
Excluding content from GitHub Copilot - GitHub Docs
Copilot content exclusion is now generally available in IDEs - GitHub Changelog



