When you open a large repository, GitHub Copilot can take a long time to index files before it starts suggesting code. This delay happens because Copilot builds a local context index for your project to understand your codebase. The indexing process scans every file, which can be slow in repos with thousands of files or massive directories. This article explains why indexing is slow in large repos and provides concrete steps to speed it up.
Key Takeaways: Speed Up GitHub Copilot Indexing
- VS Code settings.json > git copilot.advanced indexingExcludePatterns: Exclude large or irrelevant directories from indexing to reduce scan time.
- .copilotignore file in repo root: Define patterns to skip files like node_modules, build outputs, and generated code.
- Copilot status in VS Code status bar: Check indexing progress and restart if stuck to avoid waiting indefinitely.
Why GitHub Copilot Indexing Is Slow in Large Repositories
GitHub Copilot indexing builds a local vector index of your code to provide context-aware suggestions. When you open a repo, Copilot scans all files in the workspace. For large repos with tens of thousands of files, this scan can take several minutes. The index is rebuilt each time you open the folder or when file changes are detected.
The primary bottleneck is file system I/O. Scanning every file and reading its contents for indexing consumes CPU and disk resources. Repos with large binary files, minified JavaScript, or generated code exacerbate the problem because Copilot still tries to index them. Additionally, the index is stored locally and may need to be rebuilt if the repo is cloned fresh or if the Copilot extension updates.
Copilot does not index files that are ignored by your version control system. However, many developers do not configure .gitignore properly, leaving large folders like node_modules or build artifacts in the workspace. Copilot indexes these by default unless you explicitly exclude them.
Steps to Speed Up GitHub Copilot Indexing
Method 1: Exclude Directories in VS Code Settings
- Open VS Code settings
Press Ctrl+, on Windows or Cmd+, on Mac. This opens the Settings editor. - Search for indexing exclude patterns
Typegit copilot.advanced indexingExcludePatternsin the search bar. This setting controls which files Copilot skips during indexing. - Add exclusion patterns
Click Add Item. Enter a glob pattern likenode_modules/to exclude the node_modules folder. Add patterns for other large directories such asbuild/,dist/,.next/, andvendor/. - Save and reload the window
Close the Settings tab. Reload the VS Code window by pressing Ctrl+Shift+P and running Developer: Reload Window. Copilot re-indexes using the new exclusion list.
Method 2: Use a .copilotignore File
- Create a .copilotignore file in your repo root
Open the root folder of your repository. Create a new file named.copilotignore. - Add exclusion patterns
Write glob patterns, one per line. For example:node_modules/build/min.jsmapgenerated/
These patterns tell Copilot to skip those files during indexing. - Save the file and restart Copilot
Save the .copilotignore file. Open the Command Palette with Ctrl+Shift+P and search for GitHub Copilot: Restart Copilot. Click it to force a re-index with the new ignore rules.
Method 3: Reduce Workspace Scope
- Open only the subfolder you need
Instead of opening the entire mono-repo, open a subfolder that contains the code you are actively editing. For example, if you work on a service insidesrc/services/payments, open that folder in VS Code. - Use multi-root workspaces
If you need access to multiple parts of the repo, create a workspace file that includes only the relevant folders. Go to File > Add Folder to Workspace and select only the directories you need. Copilot indexes only the folders you add. - Save the workspace file
Save the workspace as a .code-workspace file. Next time you open it, Copilot indexes only the selected folders.
Method 4: Disable Indexing for a Specific Language
- Open VS Code settings
Press Ctrl+, or Cmd+,. - Search for language exclusions
Typegit copilot.advanced indexingExcludeLanguages. - Add languages to exclude
Click Add Item and enter a language identifier such asmarkdown,yaml, orjson. Copilot skips files of those languages during indexing. This is useful for repos with many documentation or config files.
If Copilot Still Has Slow Indexing After the Main Fix
Indexing progress bar shows 0% for minutes
Copilot may get stuck if the index file is corrupted. Open the Command Palette and run GitHub Copilot: Restart Copilot. If that does not help, run Developer: Reload Window to force a fresh index rebuild.
Copilot suggestions are missing or generic despite indexing
The index may be incomplete if the repo contains symlinks or files outside the workspace. Ensure all your code files are inside the opened folder. Also check that your .copilotignore file does not accidentally exclude source code directories like src/.
Indexing restarts every time you switch branches
When you switch branches, file timestamps change. Copilot detects these changes and re-indexes modified files. To reduce this, ensure you have a stable .gitignore that excludes generated files. You can also disable automatic indexing for large generated files by adding them to .copilotignore.
Copilot Indexing Performance: Default vs Optimized
| Item | Default Configuration | Optimized Configuration |
|---|---|---|
| Indexing scope | All files in the workspace | Only source code files, excluding node_modules, build, and generated files |
| Indexing time for 50k files | 5-10 minutes | 30 seconds to 2 minutes |
| Exclusion method | None by default | .copilotignore file or VS Code settings patterns |
| Language support | All languages indexed | Only relevant languages included |
| Re-index on branch switch | Full re-index | Partial re-index only for changed files |
You can now reduce Copilot indexing time in large repos by excluding irrelevant directories and files. Start by creating a .copilotignore file in your repo root with patterns for node_modules, build, and generated code. Then adjust VS Code settings to exclude languages you do not need. For mono-repos, open only the subfolder you are working on to limit the indexing scope. A well-configured .copilotignore can cut indexing time from several minutes to under a minute.