Skip to main content

Configuring content exclusions for GitHub Copilot

You can prevent GitHub Copilot from accessing certain content.

Quem pode usar esse recurso?

Repository administrators and organization owners can manage content exclusion settings.

People with the "Maintain" role for a repository can view, but not edit, content exclusion settings for that repository.

Organizações com uma assinatura de GitHub Copilot Business ou GitHub Copilot Enterprise.

Note

Configuring content exclusions for your repository

You can use your repository settings to specify content in your repository that GitHub Copilot should ignore.

  1. No GitHub.com, navegue até a página principal do repositório.

  2. Abaixo do nome do repositório, clique em Configurações. Caso não consiga ver a guia "Configurações", selecione o menu suspenso , clique em Configurações.

    Captura de tela de um cabeçalho de repositório que mostra as guias. A guia "Configurações" é realçada por um contorno laranja-escuro.

  3. In the "Code & automation" section of the side bar, click Copilot.

    If your repository inherits any exclusions from organizations in the same enterprise, you'll see one or more gray boxes at the top of the page containing details of these exclusions. You cannot edit these settings.

  4. In the box following "Paths to exclude in this repository," enter the paths to files from which Copilot should be excluded.

    Use the format: - "/PATH/TO/DIRECTORY/OR/FILE", with each path on a separate line. You can add comments by starting a line with #.

    Tip

    You can use fnmatch pattern matching notation to specify file paths. Patterns are case insensitive. See "File" in the ruby-doc.org documentation.

Example of paths specified in the repository settings

YAML
- "/src/some-dir/kernel.rs"

Ignore the /src/some-dir/kernel.rs file in this repository.

- "secrets.json"

Ignore files called secrets.json anywhere in this repository.

- "secret*"

Ignore all files whose names begin with secret anywhere in this repository.

- "*.cfg"

Ignore files whose names end with .cfg anywhere in this repository.

- "/scripts/**"

Ignore all files in or below the /scripts directory of this repository.

# Ignore the `/src/some-dir/kernel.rs` file in this repository.
- "/src/some-dir/kernel.rs"

# Ignore files called `secrets.json` anywhere in this repository.
- "secrets.json"

# Ignore all files whose names begin with `secret` anywhere in this repository.
- "secret*"

# Ignore files whose names end with `.cfg` anywhere in this repository.
- "*.cfg"

# Ignore all files in or below the `/scripts` directory of this repository.
- "/scripts/**"

Configuring content exclusions for your organization

You can use your organization settings to specify content in any Git repository that GitHub Copilot should ignore.

  1. No canto superior direito de GitHub, selecione sua foto de perfil e selecione Suas organizações.

  2. Ao lado da organização, clique em Configurações.

  3. In the left sidebar, click Copilot then click Content exclusion.

  4. In the box following "Repositories and paths to exclude," enter details of where Copilot should be excluded.

    For each repository in which you want files to be excluded from Copilot, enter a reference to the repository on one line, followed by paths to locations within the repository, with each path on a separate line. Use the following format:

    REPOSITORY-REFERENCE:
      - "/PATH/TO/DIRECTORY/OR/FILE"
      - "/PATH/TO/DIRECTORY/OR/FILE"
      - ...
    

    Repositories can be referenced using various protocols. You can use any of the following syntaxes for REPOSITORY-REFERENCE and Copilot will match them regardless of how the repository was cloned locally:

    http[s]://host.xz[:port]/path/to/repo.git/
    
    git://host.xz[:port]/path/to/repo.git/
    
    [user@]host.xz:path/to/repo.git/
    
    ssh://[user@]host.xz[:port]/path/to/repo.git/
    

Formatting tips for REPOSITORY-REFERENCE

  • You can use fnmatch pattern matching notation to specify file paths. Patterns are case insensitive. See "File" in the ruby-doc.org documentation.
  • The user@ and :port parts of the REPOSITORY-REFERENCE are ignored in the calculation of which paths to ignore for a repository.
  • Each repository reference can contain a single * wildcard. For example, https://github.com/octo-org/* matches all repositories in the octo-org organization.
  • For Azure DevOps, you can use the new (dev.azure.com) or old (visualstudio.com) host format when specifying REPOSITORY-REFERENCE, and Copilot will match them regardless of which host was used to clone the repository locally.

Example of repositories and paths in organization settings

YAML
"*":
  - "**/.env"

Ignore all .env files at any path, in any repository. This setting applies to all repositories, not just to those on GitHub.com. This could also have been written on a single line as:

"*": ["**/.env"]

octo-repo:

In the octo-repo repository in this organization:

  - "/src/some-dir/kernel.rs"

Ignore the /src/some-dir/kernel.rs file.

https://github.com/primer/react.git:

In the primer/react repository on GitHub:

  - "secrets.json"

Ignore files called secrets.json anywhere in this repository.

  - "/src/**/temp.rb"

Ignore files called temp.rb in or below the /src directory.

git@github.com:*/copilot:

In the copilot repository of any GitHub organization:

  - "/__tests__/**"

Ignore any files in or below the /__tests__ directory.

  - "/scripts/*"

Ignore any files in the /scripts directory.

git@gitlab.com:gitlab-org/gitlab-runner.git:

In the gitlab-org/gitlab-runner repository on GitLab:

  - "/main_test.go"

Ignore the /main_test.go file.

  - "{server,session}*"

Ignore any files with names beginning with server or session anywhere in this repository.

  - "*.m[dk]"

Ignore any files with names ending with .md or .mk anywhere in this repository.

  - "**/package?/*"

Ignore files directly within directories such as packages or packaged anywhere in this repository.

  - "**/security/**"

Ignore files in or below any security directories, anywhere in this repository.

# Ignore all `.env` files at any path, in any repository.
# This setting applies to all repositories, not just to those on GitHub.com.
# This could also have been written on a single line as:
#
# "*": ["**/.env"]
"*":
  - "**/.env"

# In the `octo-repo` repository in this organization:
octo-repo:
  # Ignore the `/src/some-dir/kernel.rs` file.
  - "/src/some-dir/kernel.rs"

# In the `primer/react` repository on GitHub:
https://github.com/primer/react.git:
  # Ignore files called `secrets.json` anywhere in this repository.
  - "secrets.json"
  # Ignore files called `temp.rb` in or below the `/src` directory.
  - "/src/**/temp.rb"

# In the `copilot` repository of any GitHub organization:
git@github.com:*/copilot:
  # Ignore any files in or below the `/__tests__` directory.
  - "/__tests__/**"
  # Ignore any files in the `/scripts` directory.
  - "/scripts/*"

# In the `gitlab-org/gitlab-runner` repository on GitLab:
git@gitlab.com:gitlab-org/gitlab-runner.git:
  # Ignore the `/main_test.go` file.
  - "/main_test.go"
  # Ignore any files with names beginning with `server` or `session` anywhere in this repository.
  - "{server,session}*"
  # Ignore any files with names ending with `.md` or `.mk` anywhere in this repository.
  - "*.m[dk]"
  # Ignore files directly within directories such as `packages` or `packaged` anywhere in this repository.
  - "**/package?/*"
  # Ignore files in or below any `security` directories, anywhere in this repository.
  - "**/security/**"

Next steps

To test your changes, see "Testing changes to content exclusions in your IDE."