Stay organized with collections
Save and categorize content based on your preferences.
Gemini Code Assist supports excluding files from your context for code
generation, code completion, code transformation, and chat. For Enterprise
users, this also includes code customization.
In many scenarios, you'll have specific files or subtrees that you don't want
to have included in your context.
You can exclude these files through the use of an .aiexclude or .gitignore
file.
Write an .aiexclude file
An .aiexclude file follows the following syntax:
Examples
The following examples demonstrate how you can configure an .aiexclude file:
Block all files named apikeys.txt at or below the directory that contains
the .aiexclude file:
apikeys.txt
Block all files with the .key file extension at or below the directory that
contains the .aiexclude file:
*.key
Block only the apikeys.txtfile at the same directory as the .aiexclude
file, but not any subdirectories:
/apikeys.txt
Block all files in the directory my/sensitive/dir and all subdirectories.
The path should be relative to the directory that contains the .aiexclude
file.
my/sensitive/dir/
Blocks all the files in directory foo and its subdirectories except file
named bar.txt in the foo directory.
foo/*
!foo/bar.txt
Control access to index for code customization
By default, code customization indexes all the
supported code files
in your specified repositories.
To prevent exposure of code that you don't want to to be used in the context,
you can use branch patterns to
control access to your index
and use a stable branch, such as main.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-05 UTC."],[[["Gemini Code Assist indexes all supported code files in specified repositories by default, but users can exclude certain files."],["An `.aiexclude` file, similar in syntax to `.gitignore`, can be created to exclude specific files or subtrees from being indexed."],["An empty `.aiexclude` file blocks all files within its directory and sub-directories, while patterns within the `.aiexclude` file allow excluding specific file names, extensions, or directory paths."],["Files added to the `.aiexclude` file are dropped from the index within 24 hours if they were previously included."]]],[]]