Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 27 of 30
❮Prev Next❯

GitHub Copilot Content Exclusions and Editor Settings

Module 6: Privacy & Safeguards ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Content exclusions stop GitHub Copilot from using chosen files. A repository admin lists paths under Settings › Copilot › Content exclusion; an organization admin writes YAML that maps repositories (or "*" for all) to paths; enterprises can set them too. In supported IDEs an excluded file gets no inline suggestions and isn't used as context for other files. Exclusions need Copilot Business or Enterprise, can take up to 30 minutes to reach an open IDE, show up in the audit log, and don't apply to every Copilot feature. Separately, the github.copilot.enable editor setting turns completions on or off per language for you only.

    Simulate it » No Azure account needed

    Exam objective: 6.1.1 Configure content exclusions and editor settings. 2.1.3 Configure content exclusions for specific files or repositories (app knowledge). (Skills measured as of August 7, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    VS Code & GitHub: Configure content exclusions Exclude paths in a repository and across an organization.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading…

    In <strong>repository settings › Copilot › Content exclusion</strong>, list the paths Copilot must ignore. Organization and enterprise admins can exclude paths across many repositories.

    👆 Click the glowing item on screen to continue

    Read the steps as text
    1. In repository settings › Copilot › Content exclusion, list the paths Copilot must ignore. Organization and enterprise admins can exclude paths across many repositories.
    2. At the organization level, write YAML: a repository name (or "" for all) and its paths.
    3. Open an excluded file and the Copilot status icon shows it’s excluded: no inline suggestions, and the file isn’t used as context for other files.
    4. Editor settings are personal: turn completions off for languages such as plaintext or YAML. Note that exclusions don’t cover every Copilot feature, so check the docs for the ones you rely on.

    🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.

    😟 THE PROBLEM

    Copilot could read a folder of production keys as context.

    😊 THE SOLUTION

    Exclude sensitive paths in repository or organization settings.

    • Secrets as context✓ Exclude /secrets/**
    • Many repositories✓ Org-level exclusions
    • Change not visible yet✓ Up to 30 minutes, or reload
    🛠️ Solved with: Content exclusions

    Start with a question

    The payment key lives in config/secrets.js, and that file is open in a tab while you code. Is Copilot reading it?

    It can. When you’re typing in src/cart.js, Copilot builds its prompt from the code around your cursor and from snippets in your other open tabs. If config/secrets.js is one of those tabs, bits of it may be sent along.

    Nobody did anything wrong here. That’s how Copilot finds useful context. But your security team would rather that file never went anywhere, and asking 40 developers to “close that tab” isn’t a control.

    A content exclusion is the control. An admin lists the path once, and Copilot leaves that file alone for everyone in the repository.

    Explain it like I’m 10

    Visual: Content exclusions in motion

    Watch a secret file get pulled into Copilot’s context, then left out once an admin excludes it.

    ▶ Explainer video See it in motion 8 steps · 1 min 37 sec

    An animation of content exclusions in GitHub Copilot. A developer in the contoso-shop repository has cart.js, discount.js and config/secrets.js open, and all three feed the prompt. A repository admin adds /config/secrets.js under Settings, Copilot, Content exclusion. After up to 30 minutes (or a window reload) the excluded file stops being sent as context, and opening it shows no inline suggestions with a status bar note. An organization YAML rule then excludes every .env file in all repositories. The video ends with the limits: exclusions are for Business and Enterprise, not every Copilot feature honours them, and the github.copilot.enable setting is a personal editor switch, not a security control.
    Read the video script
    1. Copilot reads your open tabsYou're working in cart.js in the contoso-shop repo. To suggest the next line, Copilot sends the code around your cursor, plus snippets from the other files you have open.
    2. A secret file goes along tooBut secrets.js is open too. Nothing stops its contents from going along as context. That's the file your security team wants Copilot to ignore.
    3. Exclude the path in the repositoryA repository admin opens Settings, then Copilot, then Content exclusion, and adds the path. This needs Copilot Business or Enterprise.
    4. Give it time to reach the IDEThe change isn't instant. It can take up to thirty minutes to reach an editor that's already open. Reloading the window picks it up sooner.
    5. The file stays out of the promptNow when you type in cart.js, only cart.js and discount.js go into the prompt. The excluded file is left out.
    6. Open the excluded fileOpen secrets.js itself and you get no inline suggestions at all. The Copilot icon in the status bar tells you the file is excluded, so you know it isn't broken.
    7. One rule for every repositoryOrganization admins can go wider. They write a little YAML: a repo name, or a star for every repo, and the paths. Here, every dot env file in contoso is excluded.
    8. Know what it coversLast, know the limits. Not every Copilot feature honours exclusions, so check the docs for the ones you use. And turning Copilot off for a language in your editor is a personal choice, not a security control.

    The technical explanation

    Content exclusions are part of Copilot Business and Copilot Enterprise. Individual plans (Free, Pro, Pro+) don’t have them.

    What an excluded file means in the IDE

    In supported IDEs, when a file matches an exclusion:

    • Copilot gives no inline suggestions inside it.
    • Copilot doesn’t use it as context for suggestions in other files.
    • The Copilot status icon says the file is excluded, so developers can tell “blocked on purpose” from “broken”.

    The file isn’t hidden, encrypted or changed. You can still open and edit it. Exclusions also don’t apply to every Copilot feature, so check GitHub’s docs for the features your team relies on before you promise anything.

    Three places to set them

    LevelWhoFormatReach
    RepositoryRepository adminList of paths, one per lineThat repository
    OrganizationOrganization ownerYAML: repository name (or "*") → pathsNamed repos, or all of them
    EnterpriseEnterprise ownerYAML, like the organizationRepositories across the enterprise

    Repository level, under Settings › Copilot › Content exclusion:

    - "/config/secrets.js"   # one file, from the repository root
    - "/secrets/**"          # everything under /secrets
    - "*.pem"                # any .pem file anywhere

    Organization level, under Organization settings › Copilot › Content exclusion:

    contoso-shop:
      - "/src/legacy/report.js"
    "*":
      - "**/.env"

    Paths use fnmatch-style patterns. A leading / anchors the path at the repository root. Without it, the pattern can match in any folder, which is sometimes what you want and sometimes a surprise.

    Timing and the audit log

    An exclusion change can take up to 30 minutes to reach IDEs that are already open. If a developer still sees suggestions right after you save, ask them to reload the window before you start debugging. Every change to exclusions is recorded in the organization’s audit log as a copilot. event, so you can see who changed what.

    Editor settings are a different thing

    Each developer can switch inline completions on or off per language in VS Code:

    "github.copilot.enable": {
      "*": true,
      "plaintext": false,
      "markdown": false,
      "yaml": false
    }

    That’s handy when ghost text gets in the way of writing docs. But it’s personal. Anyone can flip it back, and it does nothing for the next developer. If a file is sensitive, the answer is a content exclusion set by an admin, not an editor preference.

    Architect level Exclusions are a second line, not the first

    An exclusion stops Copilot reading a file. It doesn’t stop the secret being in Git history, in a fork, or on a laptop. The first line is keeping secrets out of the repository: environment variables, a secrets manager, and secret scanning with push protection so a key can’t be pushed by mistake. Use exclusions for files that must live in the repo but shouldn’t feed an AI tool, such as licensed third-party code or customer data samples.

    Real-world business scenario

    Online retail

    Contoso (fictional)

    The problem
    The contoso-shop repo kept a vendor's licensed tax engine under /vendor/tax and a config file with test card numbers. Legal didn't want either used as Copilot context, and the team had 30 repositories with .env files.
    What they used
    A repository exclusion for /vendor/tax/** and /config/test-cards.json, plus one organization rule that excludes **/.env in every repository, on Copilot Business.
    Why that choice
    One org rule covered all 30 repositories, including new ones, and the audit log showed legal exactly when each rule was added.
    The result
    Developers open those files and see the excluded status instead of suggestions, and nobody has to remember to close tabs.

    When to use it and when not to

    ✓ Use it when…

    • Files with secrets, keys or customer data that must stay in the repository.
    • Licensed or third-party code your legal team doesn't want used as AI context.
    • An org-wide rule, such as every .env file, across many repositories.

    ✕ Think twice when…

    • As your only protection for secrets. Keep them out of the repo and use secret scanning.
    • When you only want fewer suggestions while writing docs. Use github.copilot.enable instead.
    • On individual plans. Exclusions need Copilot Business or Enterprise.

    ↔ Alternatives to consider

    • Secret scanning with push protection to stop secrets reaching the repository.
    • github.copilot.enable for a personal, per-language on/off switch.
    • Organization policies to turn whole Copilot features off.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    Your company uses GitHub Copilot Business. A repository named contoso-shop contains a folder named /config that holds sensitive configuration files. You need to prevent Copilot from using files in that folder for suggestions or as context. The solution must affect only this repository. What should you configure?

    Question 2

    Question 2 of 5

    An organization owner must exclude every .env file in all repositories in the organization from GitHub Copilot, including repositories created in the future. Which organization-level content exclusion meets the requirement?

    Question 3

    Question 3 of 5 · Select 2

    A file in a repository matches a content exclusion. Which TWO behaviors should a developer expect in a supported IDE? Each correct answer presents a complete solution.

    Question 4

    Question 4 of 5

    A developer on Copilot Business finds that inline suggestions are distracting when writing Markdown documentation. Suggestions must remain available in all other languages. The developer has no administrative rights. What should the developer do?

    Question 5

    Question 5 of 5

    A developer uses GitHub Copilot Pro on personal repositories and wants to configure content exclusions. What should you tell the developer?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner What does a content exclusion actually do to a file?

    Model answer

    In a supported IDE, Copilot won't offer inline suggestions inside that file, and it won't pull snippets from it as context when I'm working in other files. The file itself isn't changed or hidden from me.

    Interviewer follows up

    How do you know it's working?

    You

    I open the file and look at the Copilot icon in the status bar. It says the file is excluded, and no ghost text appears.

    Intermediate Where can content exclusions be set, and who can set them?

    Model answer

    Three places. A repository admin sets paths for one repository. An organization owner writes YAML that can target named repositories or all of them with "*". An enterprise owner can set rules across the enterprise. All of it needs Copilot Business or Enterprise.

    Experienced developer A developer says they can still see suggestions in a file you excluded ten minutes ago. Is the exclusion broken?

    Model answer

    Probably not. Exclusion changes can take up to 30 minutes to reach an IDE that's already open. I'd ask them to reload the window, check the status icon, and confirm the path pattern actually matches the file, for example a leading slash for the repository root.

    Interviewer follows up

    And if it still doesn't match after a reload?

    You

    I'd check the pattern against the real path, check they're using a supported IDE and an up-to-date extension, and check which Copilot feature they mean, because exclusions don't cover every feature.

    Scenario Your security team wants every .env file in the company ignored by Copilot. How do you do it with the least effort?

    Model answer

    One organization-level rule with "*" as the repository and "**/.env" as the path. That covers every repository in the org, including new ones, without touching each repository's settings. The change appears in the audit log.

    Architecture & design Is turning off Copilot for YAML in VS Code a good way to protect your infrastructure files?

    Model answer

    No. github.copilot.enable is a personal editor setting. Anyone can switch it back, and it does nothing for other developers. If the files are sensitive, the control is a content exclusion set by an admin, backed by not storing secrets in the repo at all.

    Quick revision

    Key points

    • Content exclusions are a Copilot Business and Enterprise feature.
    • Repository level is a list of paths; organization level is YAML mapping a repository (or "*") to paths; enterprises can also set them.
    • Excluded files get no inline suggestions and aren't used as context in supported IDEs.
    • Changes can take up to 30 minutes to reach an open IDE. Reloading the window helps.
    • Exclusions don't apply to every Copilot feature, so check the docs for the ones you rely on.
    • Exclusion changes are recorded in the audit log.
    • github.copilot.enable switches completions per language for one user. It isn't a security control.

    Important terminology

    Content exclusion
    A Copilot Business or Enterprise setting that lists files or paths Copilot must not use for suggestions or as context.
    Repository-level exclusion
    A list of paths, one per line, set under the repository's Settings › Copilot › Content exclusion. It applies to that repository only.
    Organization-level exclusion
    YAML set by an organization owner that maps a repository name, or "*" for every repository, to the paths to exclude.
    fnmatch pattern
    The glob style used for exclusion paths, such as "/secrets/**" or "*.pem".
    github.copilot.enable
    A VS Code setting that turns Copilot inline completions on or off per language, for example off for plaintext or YAML. It's a personal preference, not a policy.
    Copilot status icon
    The icon in the IDE status bar that shows whether Copilot is working, signed out, or disabled because the file is excluded.

    Common mistakes

    • Treating the per-language editor setting as a way to protect sensitive files.
    • Expecting an exclusion to take effect the second you save it.
    • Assuming exclusions are available on Copilot Free, Pro or Pro+.
    • Writing a path without the leading slash and matching the wrong files, or missing the right ones.

    Exam tips

    • "Stop Copilot using one folder in one repository" = repository settings › Copilot › Content exclusion.
    • "Same rule for every repository in the org" = organization YAML with "*".
    • "Excluded but still suggesting" = wait up to 30 minutes or reload the window.
    • "Turn off completions for Markdown just for me" = github.copilot.enable.

    Five quick revision questions

    1. 1.Which plans support content exclusions?Show

      Copilot Business and Copilot Enterprise.

    2. 2.What does "*" mean in an organization exclusion?Show

      Apply the listed paths to every repository in the organization.

    3. 3.How long can an exclusion change take to reach an open IDE?Show

      Up to 30 minutes.

    4. 4.Where can you see who changed an exclusion?Show

      In the audit log, as a copilot event.

    5. 5.Which VS Code setting turns completions off for one language?Show

      github.copilot.enable.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Who Owns Copilot Output, and Its Limits

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.