GitHub Copilot can suggest code snippets from public repositories on GitHub. This behavior raises concerns for enterprise users who need to avoid licensing conflicts or accidental inclusion of open-source code. By default, Copilot may match public code patterns even when you do not want them. This article explains how to disable public code suggestions in GitHub Copilot across Visual Studio Code, JetBrains IDEs, and the GitHub.com web interface.
Key Takeaways: Blocking Public Code Suggestions in GitHub Copilot
- GitHub.com > Settings > Copilot > Suggestions matching public code: Toggle off the option to block public code matches globally.
- VS Code > Settings > GitHub > Copilot > Enable Public Code Suggestions: Uncheck this checkbox to stop public code suggestions in the editor.
- JetBrains > Settings > Tools > GitHub Copilot > Suggest public code: Disable this checkbox to prevent public code matches in JetBrains IDEs.
Understanding Public Code Suggestions in GitHub Copilot
GitHub Copilot uses machine learning models trained on public code from GitHub repositories. When you type code, Copilot may suggest completions that closely match code from public repositories. This is called a public code match. For organizations with strict licensing policies, these suggestions can introduce legal risk. The GitHub Copilot settings allow you to block suggestions that match public code. This setting applies to all Copilot users in your organization or individual account. Once enabled, Copilot will only suggest code that does not match publicly available code patterns. The feature works at the account level and across supported IDEs.
Steps to Block Public Code Suggestions on GitHub.com
The first method applies to your GitHub account globally. Changes made here affect all IDEs connected to that account.
- Sign in to GitHub.com
Open your browser and go to github.com. Sign in with your GitHub account that has Copilot access. - Open Settings
Click your profile picture in the top-right corner. Select Settings from the dropdown menu. - Navigate to Copilot settings
In the left sidebar, click Copilot. This opens the Copilot configuration page. - Disable public code suggestions
Find the section labeled Suggestions matching public code. Uncheck the box next to Allow suggestions matching public code. The change saves automatically.
Steps to Block Public Code Suggestions in Visual Studio Code
If you use VS Code, you can control this setting directly from the editor. This method overrides the account-level setting for that specific IDE instance.
- Open VS Code settings
Click the gear icon in the lower-left corner of the VS Code window. Select Settings from the menu. Alternatively, press Ctrl + comma. - Search for Copilot settings
In the Settings search bar, type public code. The settings list filters to show relevant options. - Disable the public code suggestions option
Look for the setting Git > GitHub > Copilot > Enable Public Code Suggestions. Uncheck the checkbox next to it. The change takes effect immediately.
Steps to Block Public Code Suggestions in JetBrains IDEs
JetBrains IDEs like IntelliJ IDEA, PyCharm, and WebStorm have a separate Copilot settings section. The option is labeled differently.
- Open Settings in JetBrains IDE
Click File in the top menu. Select Settings from the dropdown. On macOS, click the IDE name in the menu bar and select Preferences. - Locate Copilot settings
In the Settings window, expand Tools in the left sidebar. Click GitHub Copilot. - Disable public code suggestions
Find the checkbox labeled Suggest public code. Uncheck it. Click Apply and then OK to save the change.
If Copilot Still Suggests Public Code After Disabling
Copilot continues to show matches from public repositories
If you still see public code suggestions after disabling the setting, verify that the change saved correctly. On GitHub.com, revisit the Copilot settings page and confirm the checkbox remains unchecked. In VS Code or JetBrains, reopen the settings and check the same option. Some IDEs require a restart to apply the change. Close and reopen your IDE to force a reload of Copilot settings.
Organization-level policy overrides individual settings
If you use a GitHub organization account, an administrator may have set a policy that allows public code suggestions for all members. In that case, the organization setting overrides your personal setting. Contact your GitHub organization owner and ask them to disable public code suggestions at the organization level. They can do this from the organization settings under Copilot > Policy.
Copilot in the web editor still shows public code
The GitHub.com web editor has its own Copilot settings. Follow the steps in the GitHub.com section above. If the web editor still shows public code suggestions, try clearing your browser cache and reloading the page. The setting should propagate within a few minutes.
Copilot Personal Account vs Organization Account: Public Code Settings
| Item | Personal Account | Organization Account |
|---|---|---|
| Setting location | Settings > Copilot | Organization Settings > Copilot > Policy |
| Default state | Public code suggestions enabled | Public code suggestions enabled |
| Who can change | Account owner | Organization owner or admin |
| Override behavior | None | Can override personal settings for all members |
You can now prevent GitHub Copilot from suggesting public code in your IDE and on GitHub.com. Check your organization policy if you are part of a team to ensure the setting is enforced for all members. For additional control, explore Copilot’s content exclusion settings to block specific repositories from training data.