Skip to main content

Excluding content from GitHub Copilot

You can prevent Copilot from accessing certain content.

누가 이 기능을 사용할 수 있나요?

Repository administrators, organization owners, and enterprise 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.

GitHub Copilot Business 또는 GitHub Copilot Enterprise 구독을 보유한 조직 및 엔터프라이즈입니다.

About content exclusions for Copilot

You can use content exclusions to configure Copilot to ignore certain files. When you exclude content from Copilot:

  • Code completion will not be available in the affected files.
  • The content in affected files will not inform code completion suggestions in other files.
  • The content in affected files will not inform GitHub Copilot Chat's responses.

Who can configure content exclusion

Repository administrators, organization owners, and enterprise owners can configure content exclusion.

  • 리포지토리 관리자는 자신의 리포지토리에 대한 콘텐츠만 제외할 수 있습니다. 이는 해당 특정 리포지토리 내에서 작업하는 Copilot 사용자에게 영향을 줍니다.
  • 조직 소유자는 조직을 통해 Copilot 시트가 할당된 사용자의 콘텐츠를 제외할 수 있습니다.

Note

현재 공개 미리 보기 릴리스에서 콘텐츠 제외에 대한 조직 수준 설정은 일반적으로 엔터프라이즈의 모든 Copilot 사용자에게 적용됩니다. 이 기능은 2024년 11월 8일에 이 기능의 GA(일반 공급) 릴리스에 따라 변경됩니다.

11월 8일 이전:

  • 엔터프라이즈 소유자가 규칙을 설정하지 않는 경우: 조직 수준 규칙은 11월 8일까지 현재와 같이 작동하는 엔터프라이즈 전체의 모든 사용자에게 계속 적용됩니다.
  • 엔터프라이즈 소유자가 규칙을 설정하는 경우: 엔터프라이즈 수준 규칙이 적용되면 조직 수준 규칙은 규칙이 설정된 조직에서 Copilot 시트가 할당된 사용자에게만 적용됩니다.

11월 8일 이후:

  • 조직 수준 규칙은 더 이상 엔터프라이즈 전체에 적용되지 않습니다. 규칙이 설정된 조직에서 Copilot 시트가 할당된 사용자로 제한됩니다.
  • 엔터프라이즈 소유자는 엔터프라이즈의 모든 Copilot 사용자에게 제외 규칙을 적용할 수 있습니다.

Availability of content exclusions

ToolCode completion supportCopilot Chat support
Visual Studio
Visual Studio Code
JetBrains IDEs
Vim/NeovimNot applicable
XcodeNot applicable
Azure Data StudioNot applicable
The GitHub websiteNot applicable
GitHub MobileNot applicable

Limitations of content exclusions

제외되지 않은 파일에서 IDE가 정보를 제공하는 경우 에서 제외된 파일의 의미론적 정보를 사용할 수 있습니다. 이러한 콘텐츠의 예로는 코드에 사용되는 기호에 대한 형식 정보와 커서 올리기 정의가 포함됩니다.

Data sent to GitHub

After you configure content exclusion, the client (for example, the Copilot extension for VS Code) sends the current repository URL to the GitHub server so that the server can return the correct policy to the client. These URLs are not logged anywhere.

Configuring content exclusions for your repository

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

  1. GitHub에서 리포지토리의 기본 페이지로 이동합니다.

  2. 리포지토리 이름 아래에서 Settings(설정)를 클릭합니다. "설정" 탭이 표시되지 않으면 드롭다운 메뉴를 선택한 다음 설정을 클릭합니다.

    탭을 보여 주는 리포지토리 헤더의 스크린샷. "설정" 탭이 진한 주황색 윤곽선으로 강조 표시됩니다.

  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

    fnmatch 패턴 일치 표기법을 사용하여 파일 경로를 지정할 수 있습니다. 패턴은 대/소문자를 구분하지 않습니다. ruby-doc.org 설명서의 "파일"을 참조하세요.

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 files that GitHub Copilot should ignore. The files can be within a Git repository or anywhere on the file system that is not under Git control.

  1. GitHub의 오른쪽 위 모서리에서 프로필 사진을 선택하고 조직을 클릭합니다.

  2. 조직 옆에 있는 설정을 클릭합니다.

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

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

    To exclude files located anywhere (within a Git repository or elsewhere), enter "*": followed by the path to the file, or files, you want to exclude. If you want to specify multiple file path patterns, list each pattern on a separate line.

    To exclude files in a Git repository 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, replacing REPOSITORY-REFERENCE with a reference to the repository that contains the files you'd like to exclude:

    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/
    

    The user@ and :port parts of the REPOSITORY-REFERENCE are ignored in the calculation of which paths to ignore for a repository.

    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.

    Tip

    fnmatch 패턴 일치 표기법을 사용하여 파일 경로를 지정할 수 있습니다. 패턴은 대/소문자를 구분하지 않습니다. ruby-doc.org 설명서의 "파일"을 참조하세요.

Example of repositories and paths in organization settings

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

Ignore all .env files from all file system roots (Git and non-Git). For example, this excludes REPOSITORY-PATH/.env and also /.env. 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 from all file system roots (Git and non-Git).
# For example, this excludes `REPOSITORY-PATH/.env` and also `/.env`.
# 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/**"

Configuring content exclusions for your enterprise

As an enterprise owner, you can use the enterprise settings to specify files that GitHub Copilot should ignore. The files can be within a Git repository or anywhere on the file system that is not under Git control.

  1. GitHub의 오른쪽 위 모서리에서 프로필 사진을 클릭한 다음 엔터프라이즈를 클릭합니다.

  2. 엔터프라이즈 목록에서 보려는 엔터프라이즈를 클릭합니다.

  3. 페이지 왼쪽의 엔터프라이즈 계정 사이드바에서 정책을 클릭합니다.

  4. " 정책" 섹션에서 Copilot 을(를) 클릭합니다.

  5. Click the Content exclusion tab.

  6. Use paths to specify which content to exclude. See the previous section, "Configuring content exclusions for your organization."

Note

The key difference between setting content exclusion at the enterprise level and the organization level is that rules set at the enterprise level apply to all Copilot users in the enterprise, whereas the rules set by organization owners only apply to users who are assigned a Copilot seat by that organization.

Testing changes to content exclusions

You can use your IDE to confirm that your changes to content exclusions are working as expected.

Propagate content exclusion changes to your IDE

After you add or change content exclusions, it can take up to 30 minutes to take effect in IDEs where the settings are already loaded. If you don't want to wait, you can manually reload the content exclusion settings using the following instructions.

  • For JetBrains IDEs and Visual Studio, reload the content exclusion settings by closing and reopening the application.
  • For Visual Studio Code, use the following steps to reload the content exclusion settings:
    1. Access the Command Palette. For example, by pressing Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux).
    2. Type: reload.
    3. Select Developer: Reload Window.
  • For Vim/Neovim, content exclusions are automatically fetched from GitHub each time you open a file.

Test your content exclusions

There are a few different ways to test your content exclusions, depending on which IDE you're using.

  1. Open a file that you expect to be affected by your content exclusions.
  2. Use one or more of the following techniques to test if content is being excluded:
    • In JetBrains IDEs, Visual Studio, and Visual Studio Code, check the Copilot icon in the status bar. If a Copilot content exclusion applies to the file, the Copilot icon will have a diagonal line through it. Hover over the icon to see whether an organization or the parent repository disabled Copilot for the file.
    • In Vim/Neovim, begin typing in the file. If GitHub Copilot no longer provides inline suggestions as you type, the file is excluded.
    • You can also test content exclusions in Copilot Chat. Open the Copilot Chat window, and ask Copilot Chat a question about the excluded file. If your content is excluded successfully, Copilot will be unable to answer your question, and will explain that some files were excluded from the conversation due to content exclusion rules.

Further reading