リポジトリのコンテンツ除外の構成
リポジトリ設定を使用して、GitHub Copilot で無視するようにするリポジトリ内のコンテンツを指定できます。
- 
GitHub で、リポジトリのメイン ページに移動します。 
- 
リポジトリ名の下にある [Settings] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。 ![タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。](/assets/cb-28260/images/help/repository/repo-actions-settings.png) 
- 
サイド バーの [Code & automation] セクションで、 [Copilot] をクリックしてから、[Content exclusion] をクリックします。 リポジトリが親 organization から、または同じ Enterprise 内の organization から除外を継承している場合、ページの上部に、これらの除外の詳細を含む灰色のボックスが 1 つ以上表示されます。 これらの設定は編集できません。 
- 
[このリポジトリで除外するパス] のボックスに、Copilot を除外するファイルへのパスを入力します。 各パスを別々の行にして、形式 - "/PATH/TO/DIRECTORY/OR/FILE"を使用します。 行頭を#にすることで、コメントを追加できます。ヒント fnmatch パターン マッチング表記を使用して、ファイル パスを指定できます。 パターンでは大文字と小文字が区別されません。 ruby-doc.org ドキュメントの「ファイル」を参照してください。 
リポジトリ設定で指定されたパスの例
# 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/**"
- "/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/**"
Organization のコンテンツ除外の構成
組織設定を使用して、GitHub Copilot を無視するようにするファイルを指定できます。 ファイルは、Git リポジトリ内、または Git の管理下にないファイル システム上の任意の場所に配置できます。
- 
GitHub の右上隅にあるプロフィール画像をクリックしてから、[ Your organizations] をクリックします。 
- 
組織の隣の [設定] をクリックします。 
- 
左側のサイドバーで、 [Copilot] をクリックしてから、[Content exclusion] をクリックします。 
- 
[除外するリポジトリとパス] のボックスに、Copilot を除外するファイルの詳細を入力します。 任意の場所 (Git リポジトリ内または他の場所) にあるファイルを除外するには、 "*":を入力し、その後に除外するファイル (複数可) へのパスを入力します。 複数のファイル パス パターンを指定する場合は、各パターンを個別の行に一覧表示します。Git リポジトリのファイルを Copilot から除外するには、リポジトリへの参照を 1 行に入力し、その後にリポジトリ内の場所へのパスを各パスが別々の行になるように入力します。 次の形式を使用して、 REPOSITORY-REFERENCEを、除外するファイルを含むリポジトリへの参照に置き換えます。REPOSITORY-REFERENCE: - "/PATH/TO/DIRECTORY/OR/FILE" - "/PATH/TO/DIRECTORY/OR/FILE" - ...リポジトリは、さまざまなプロトコルを使用して参照できます。 REPOSITORY-REFERENCEには、次のいずれかの構文を使用できます。また、リポジトリのローカルでの複製方法に関係なく、Copilot はこれらの構文と一致します。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/リポジトリに対して無視するパスの計算では、 REPOSITORY-REFERENCEのuser@部分と:port部分は無視されます。Azure DevOps では、 REPOSITORY-REFERENCEを指定するときに新しい (dev.azure.com) または古い (visualstudio.com) ホスト形式を使用でき、どのホストを使用してリポジトリをローカルにクローンしたかに関係なく、Copilot はそれらに一致します。ヒント fnmatch パターン マッチング表記を使用して、ファイル パスを指定できます。 パターンでは大文字と小文字が区別されません。 ruby-doc.org ドキュメントの「ファイル」を参照してください。 
組織設定のリポジトリとパスの例
# 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/**"
"*":
  - "**/.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/**"
Enterprise のコンテンツ除外の構成
エンタープライズのオーナーは、エンタープライズ設定を使用して、GitHub Copilot で無視するファイルを指定できます。 ファイルは、Git リポジトリ内、または Git の管理下にないファイル システム上の任意の場所に配置できます。
- GitHub の右上隅にあるプロフィール画像をクリックします。
- ご自分の環境に応じて、[Your enterprise] または [Your enterprises] をクリックし、表示するエンタープライズをクリックします。
- ページの上部にある [ Policies] をクリックします。 1. [Policies] セクションで [Copilot] をクリックします。
- ページの上部にタブが表示されている場合は、[Content exclusion] タブをクリックします。そうでない場合は、[Content exclusion] の横にある アイコンをクリックします。
- パスを使用して、除外するコンテンツを指定します。 前のセクション「Organization のコンテンツ除外の構成」をご覧ください。
メモ
エンタープライズ レベルでのコンテンツ除外の設定と組織レベルでの設定の主な違いは、エンタープライズ レベルで設定されたルールは、エンタープライズ内のすべての Copilot ユーザーに適用されるのに対し、組織のオーナーが設定したルールは、組織が Copilot シートに割り当てたユーザーにのみ適用される点です。
コンテンツ除外の変更をテストする
IDE を使用して、コンテンツ除外の変更が想定どおりに動作していることを確認できます。
IDE にコンテンツ除外の変更を伝達する
コンテンツの除外を追加または変更し、設定が既に読み込まれている IDE で有効になるまでに最大で 30 分かかることがあります。 待機しない場合は、次の手順を使用して、コンテンツの除外設定を手動で再読み込みできます。
- JetBrains IDE と Visual Studio の場合は、アプリケーションを閉じて再度開くことで、コンテンツの除外設定を再読み込みします。
- Visual Studio Code の場合は、次の手順に従ってコンテンツの除外設定を再読み込みします。
- コマンド パレットにアクセスします。 たとえば、Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux) を押します。
- 次のコマンドを入力します: reload
- [開発者: ウィンドウをリロードする] を選択します。
 
- Vim/Neovim については、ファイルを開くたびに GitHub からコンテンツ除外が自動的にフェッチされます。
コンテンツの除外をテストする
構成したコンテンツ除外が想定どおりに動作していることを確認できます。
- まず、コンテンツ除外の対象ではないファイルで、コンテンツ除外が機能していることを確認します。 手順は次のとおりです。
- IDE で、コンテンツ除外の対象ではないファイルを開きます。
- 通常はコード補完候補を生成する編集を行います。 候補が提供される必要があります
 
- 除外される必要があるファイルを開き、同じ編集を行います。 候補が提供されない必要があります。
- Copilot Chat でコンテンツ除外をテストするには:
- 
IDE で Copilot Chat パネルを開きます。 
- 
除外される必要があるファイルを開き、エディターで開いている他のファイルを閉じます。 
- 
開いているファイルがコンテキスト ファイルとしてプロンプトに添付されることを確認します。 
- 
プロンプト explain this fileを入力します。ファイルが除外されている場合、Copilot Chat はそのファイルを使って応答を生成できなくなります。 ファイルは、Copilot の応答で参照として一覧に表示されません。 
 
-