Skip to main content

Configuring content exclusions for GitHub Copilot

You can prevent specified files from being used to inform code completion suggestions made by GitHub Copilot. GitHub Copilot will not be available in excluded files.

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

Repository administrators and organization owners can manage the content exclusion settings for GitHub Copilot.

People with the "Maintain" role for a repository can view the content exclusion settings for that repository, but can't change these settings. For more information, see "조직의 리포지토리 역할."

This feature is available for organization and enterprise accounts with a Copilot Business subscription, and for enterprise accounts with a Copilot Enterprise subscription.

Note:

  • GitHub Copilot은(는) 현재 퍼블릭 베타 버전이며 변경될 수 있습니다.
  • 이 기능은 GitHub Copilot, , Visual Studio Code, JetBrains IDE 및 neovim에서 코드 완료에 대해 지원됩니다. VS Code의 GitHub Copilot Chat에도 지원됩니다. 지원되는 JetBrains IDE에 대한 자세한 내용은 "편집기에서 GitHub Copilot 코드 제안 사용"을 참조하세요.

About configuring content exclusions

You may want to prevent certain files from being available to GitHub Copilot. You can configure GitHub Copilot so that it ignores these files. You do this by specifying paths to excluded content in the settings for your repository or organization.

When you specify content exclusions it has two effects:

  • The content of the affected files will not be used by GitHub Copilot to inform the code completion suggestions it makes in other files.
  • GitHub Copilot code completion will not be available in the affected files.

콘텐츠 제외를 추가하거나 변경한 후 설정이 이미 로드된 IDE에서 적용되려면 최대 30분이 걸릴 수 있습니다. 사용자 고유의 IDE에 변경 내용을 적용하여 콘텐츠 제외 설정을 다시 로드할 수 있습니다. For more information, see "Propagating content exclusion changes to your IDE."

Limitations

  • Visual Studio Code을(를) 제외한 콘텐츠 제외는 현재 GitHub Copilot Chat에 대해 지원되지 않습니다.
  • 콘텐츠 제외는 Copilot이(가) 제외된 파일의 콘텐츠에 직접 액세스하지 못하게 합니다. Copilot은(는) IDE에서 제공하는 의미 체계 정보(예: 코드에 사용되는 기호에 대한 형식 정보 또는 가리키기 정의)에서 제외되지 않은 파일에 대한 정보를 그릴 수 있습니다. IDE가 제외된 파일에서 이 정보를 파생시킬 수 있습니다.

What can you exclude?

When you specify content exclusion in the settings for a repository, you can only exclude files in that repository.

When you specify content exclusion in the settings for an organization, you can exclude files in any Git-based repository hosted on GitHub.com or anywhere that can be accessed using any of the following syntaxes:

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/

Note: It's important to be aware that content can be excluded by the settings of any GitHub organization with a Copilot Business subscription. Excluded files may be in a repository that is not owned by the organization in which the exclusion was defined. The excluded files may also be located in a Git-based repository that is not hosted on GitHub.

Who is affected by a content exclusion setting?

GitHub Copilot 콘텐츠 제외 설정은 Copilot을(를) 사용하는 모든 사용자에게 적용되지 않습니다.

콘텐츠 제외 설정은 GitHub Copilot Business 또는 GitHub Copilot Enterprise 구독의 일부로 시트를 부여 받고 콘텐츠 제외가 구성된 동일한 조직의 구성원인 사용자에게만 적용됩니다. 지정된 파일에 액세스할 수 있는 다른 사용자는 콘텐츠 제외의 영향을 받지 않으며 코드 완성 제안도 계속 표시됩니다.

All exclusions, whether they are defined in repository settings or in organization settings, apply to all members of the organization who have been granted a Copilot seat as part of a Copilot Business subscription.

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. URLs sent to the server in this way 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.com에서 리포지토리의 기본 페이지로 이동합니다.

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

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

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

    If your repository inherits any exclusions from its parent organization, you'll see a gray box at the top of the page containing details of these exclusions. You cannot edit these settings.

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

    Screenshot of the "Paths to exclude" text box in the repository settings for Copilot.

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

    You can use fnmatch pattern matching notation to specify file paths. For more information, see "File" in the ruby-doc.org documentation.

    Note: Patterns are case insensitive.

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 secret anywhere in this repository.

- "*.cfg"

Ignore files whose names end .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 `secret` anywhere in this repository.
- "secret*"

# Ignore files whose names end `.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 repository, that GitHub Copilot should ignore.

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

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

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

  4. In the box under "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/
    

    Notes:

    • 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.
    • There is additional support for Azure DevOps URLs. For more information, see "Azure DevOps REPOSITORY-REFERENCE support."

    You can use fnmatch pattern matching notation to specify file paths. For more information, see "File" in the ruby-doc.org documentation.

    Note: Patterns are case insensitive.

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 server or session, anywhere in this repository.

  - "*.m[dk]"

Ignore any files with names ending .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 `server` or `session`, anywhere in this repository.
  - "{server,session}*"
  # Ignore any files with names ending `.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/**"

Reviewing changes to the content exclusion settings

If you are an organization owner, you can check any changes that have been made to content exclusions.

  1. Open the "Content exclusion" page in the settings for your organization (described here), or the settings for a repository (described here).

  2. Scroll to the bottom of the page.

    You will see the name of the person who last changed the settings, and information about when they made this change.

  3. Click the time of the last change.

    Screenshot of the last edited information. The time of change link is highlighted with a dark orange outline.

    Note: The time of the last change is only a link if you are an organization owner.

    The "Audit log" page for the organization is displayed, showing the most recently logged occurrences of the copilot.content_exclusion_changed action.

    If you clicked through from a repository settings page, the audit log is filtered to show only changes to content exclusions for that repository.

  4. Click the ellipsis (...) at the end of each entry to see more details.

    If the "excluded_paths" entry is truncated, hover over the truncated value to show the full entry. This displays the content of the exclusion settings after the change was saved.

    Screenshot of audit log details for the 'copilot.content_exclusion_changed' action. The ellipsis button is highlighted.

Checking the effect of a settings change

When you change Copilot's content exclusions you can check that the setting blocks Copilot from suggesting code in the specified files.

To confirm that Copilot is disabled for a file, open the file in the editor and start typing a line of code, such as a comment. Normally, you would see a code completion suggestion from Copilot as you type. If Copilot is disabled by a content exclusion, code completion suggestions will not be offered, and the file's contents will not be used to generate suggestions in other files.

Checking settings changes in your IDE

If you are working in Visual Studio, VS Code, or a supported JetBrains IDE, the Copilot icon indicates when Copilot has been disabled by a content exclusion.

  1. Open a file that you expect to be affected by your content exclusions.

    If a Copilot content exclusion applies to this file, the Copilot icon in the status bar has a diagonal line through it.

  2. Hover over this icon. A popup message tells you whether an organization or the parent repository disabled Copilot for this file.

    Screenshot of the Copilot disabled popup in the VS Code toolbar.

Note: In Visual Studio and VS Code you can display the log for the Copilot extension to see details of content exclusions without having to hover over the Copilot icon. For more information, see "사용자 환경에서 GitHub Copilot에 대한 로그 보기."

Propagating content exclusion changes to your IDE

If you are working in Neovim, content exclusions are fetched from GitHub each time you open a file. However, if you are working in Visual Studio, VS Code, or a supported JetBrains IDE, you may have to wait up to 30 minutes to see the effect of a settings change. Alternatively, you can manually reload the content exclusion settings into your IDE.

To reload content exclusions into Visual Studio, close and reopen the application.

To reload content exclusions into VS Code:

  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.

To reload content exclusions into your JetBrains IDE, either close and reopen the application, or log out of GitHub and then log back in, as follows.

  1. Click the Copilot icon in the status bar and select Logout from GitHub.
  2. The Copilot icon in the status bar will now have a diagonal line through it. Click it and select Login to GitHub.
  3. The "Sign in to GitHub" message is displayed showing a device code. Click Copy and Open.
  4. On the "Device Activation" page, paste in the device code and click Continue.
  5. On the next page, click Authorize GitHub Copilot Plugin.

Azure DevOps REPOSITORY-REFERENCE support

Both the new (dev.azure.com) and old (visualstudio.com) formats for Azure DevOps are treated as equivalent in the REPOSITORY-REFERENCE syntax. You can use either host when specifying REPOSITORY-REFERENCE, and Copilot will match them regardless of which host was used to clone the repository locally.

Further reading