skip to Main Content

I’m currently using GitHub Copilot in Visual Studio Code and am trying to find a way to prevent Copilot from accessing certain file types, specifically .env files, which contain sensitive information. I attempted to disable Copilot for these files by adding ‘env’ and ‘.env’ to the list of disabled files in the Copilot settings, but this approach didn’t work, presumably because these aren’t recognized as distinct language tags in VS Code.

Has anyone successfully found a way to exclude specific files or file types from GitHub Copilot’s analysis? If so, could you please share how you achieved this?

2

Answers


  1. For disabling by language mode, see How can I disable GitHub Copilot in VS Code?. TL;DR click Copilot icon with file open, and select to disable for current language / use the github.copilot.enabled setting.

    For example, for .env files, since VS Code doesn’t have a builtin language mode for envfiles, you could install an extension that adds such language support (Ex. mikestead.dotenv (I have no affiliation with this extension)), and then add dotenv to the list of disabled language modes for GitHub copilot.


    For disabling by path, currently, you can only do this if you’re using GitHub Copilot for Business. You have to configure in in GitHub, either applying it to a repo or an org, and it will only apply to people part of your Business subscription. The pattern format is YAML with globbing.

    See the following sources:

    You can find related community discussion in the following, but at the moment there’s not much other info there:

    Login or Signup to reply.
  2. You should be a corporate owner.

    Co

    "*":
     - "**/.env"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search