با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Gemini Code Assist از حذف فایلها از زمینه شما برای تولید کد، تکمیل کد، تبدیل کد و چت پشتیبانی میکند. برای کاربران Enterprise، این شامل سفارشیسازی کد نیز میشود.
در بسیاری از سناریوها، فایلها یا زیردرختهای خاصی خواهید داشت که نمیخواهید در متن خود قرار دهید.
شما می توانید این فایل ها را با استفاده از فایل .aiexclude یا .gitignore حذف کنید.
تنظیمات حذف زمینه را پیکربندی کنید
این بخش به شما نشان می دهد که چگونه تنظیمات فایل های .aiexclude و .gitignore را پیکربندی کنید.
فایل .aiexclude را به فایل دلخواه خود تغییر دهید
بهطور پیشفرض، حذف زمینه برای استفاده از .aiexclude تنظیم شده است. برای تغییر این تنظیمات در IDE خود، این مراحل را دنبال کنید:
کد VS
در نوار فعالیت، روی تنظیماتمدیریت > تنظیمات کلیک کنید.
در پنجره تنظیمات ، به Extensions > Gemini Code Assist بروید. پیمایش کنید تا فایل Exclusion Context را پیدا کنید.
در قسمت متن، .aiexclude را به مکان دلخواه خود تغییر دهید.
فایل مورد نظر شما اکنون به عنوان فایل حذف زمینه تنظیم شده است.
IntelliJ
پیکربندی تنظیمات برای فایلهای .aiexclude و .gitignore در IDEهای JetBrains پشتیبانی نمیشود.
حذف زمینه .gitignore را تغییر دهید
به طور پیش فرض، فایل .gitignore برای حذف زمینه فعال است. فایل باید در پوشه کار ریشه Gemini Code Assist قرار داشته باشد. فایلهای .gitignore واقع در زیر شاخهها در نظر گرفته یا ادغام نمیشوند.
برای غیرفعال کردن فایلهای .gitignore از حذف زمینه، این مراحل را دنبال کنید:
در نوار فعالیت، روی تنظیماتمدیریت > تنظیمات کلیک کنید.
در پنجره تنظیمات ، به Extensions > Gemini Code Assist بروید. پیمایش کنید تا Context Exclusion Gitignore را پیدا کنید.
چک باکس را بردارید.
فایلهای .gitignore اکنون برای مشخص کردن فایل Gemini Code Assist برای نادیده گرفتن غیرفعال شدهاند.
یک فایل .aiexclude بنویسید
یک فایل .aiexclude از دستور زیر پیروی می کند:
نمونه ها
مثالهای زیر نشان میدهند که چگونه میتوانید یک فایل .aiexclude را پیکربندی کنید:
همه فایلهایی با نام apikeys.txt را در دایرکتوری حاوی فایل .aiexclude یا زیر آن مسدود کنید:
apikeys.txt
همه فایلها را با پسوند فایل .key در یا زیر دایرکتوری حاوی فایل .aiexclude مسدود کنید:
*.key
فقط فایل apikeys.txt را در همان فهرستی که فایل .aiexclude .
/apikeys.txt
همه فایلهای دایرکتوری my/sensitive/dir و همه زیر شاخهها را مسدود کنید. مسیر باید نسبت به دایرکتوری حاوی فایل .aiexclude باشد.
my/sensitive/dir/
همه فایلهای دایرکتوری foo و زیرشاخههای آن به جز فایلی با نام bar.txt در دایرکتوری foo را مسدود میکند.
برای جلوگیری از قرار گرفتن در معرض کدهایی که نمیخواهید در متن مورد استفاده قرار گیرند، میتوانید از الگوهای شاخه برای کنترل دسترسی به فهرست خود استفاده کنید و از یک شاخه پایدار مانند main استفاده کنید.
تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGemini Code Assist indexes all supported code files in your repositories by default, but you can exclude specific files or subtrees using an \u003ccode\u003e.aiexclude\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eAn \u003ccode\u003e.aiexclude\u003c/code\u003e file uses a similar syntax to \u003ccode\u003e.gitignore\u003c/code\u003e, but an empty file blocks all files in its directory and subdirectories, and negation with an exclamation point is not supported.\u003c/p\u003e\n"],["\u003cp\u003eYou can block specific files, file types, or entire directories by listing their names, extensions, or relative paths in the \u003ccode\u003e.aiexclude\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eIf a file is added to \u003ccode\u003e.aiexclude\u003c/code\u003e after being indexed, it will be removed from the index within 24 hours.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\nGemini Code Assist supports excluding files from your context for code\ngeneration, code completion, code transformation, and chat. For Enterprise\nusers, this also includes code customization.\n\nIn many scenarios, you'll have specific files or subtrees that you don't want\nto have included in your context.\n\nYou can exclude these files through the use of an `.aiexclude` or `.gitignore`\nfile.\n| **Note:** For [code customization](/gemini-code-assist/docs/code-customization-overview) only the `.aiexclude` file is used.\n\nConfigure context exclusion settings\n\nThis section shows you how to configure settings for `.aiexclude` and\n`.gitignore` files.\n\nChange .aiexclude file to your preferred file\n\nBy default, context exclusion is set to use `.aiexclude`. To change this setting\nin your IDE, follow these steps: \n\nVS Code\n\n1. In the activity bar, click\n settings **Manage** \\\u003e\n **Settings**.\n\n2. In the **Settings** window, navigate to **Extensions** \\\u003e\n **Gemini Code Assist** . Scroll until you find **Context Exclusion File**.\n\n3. In the text field, change `.aiexclude` to your preferred location.\n\nYour preferred file is now set as the context exclusion file.\n\nIntelliJ\n\nConfiguring settings for `.aiexclude` and `.gitignore` files isn't\nsupported in JetBrains IDEs.\n\nChange .gitignore context exclusion\n\nBy default, the `.gitignore` file is enabled for context exclusion. The file\nmust be located in the root working folder for\nGemini Code Assist. `.gitignore` files located in subdirectories\nwon't be considered or merged.\n\nTo disable `.gitignore` files from context exclusion, follow these steps:\n\n1. In the activity bar, click\n settings **Manage** \\\u003e\n **Settings**.\n\n2. In the **Settings** window, navigate to **Extensions** \\\u003e\n **Gemini Code Assist** . Scroll until you find **Context Exclusion Gitignore**.\n\n3. Unselect the checkbox.\n\n `.gitignore` files are now disabled for specifying file Gemini Code Assist to ignore.\n\nWrite an `.aiexclude` file **Note:** In the event that a conflict exists between `.aiexclude` and `.gitignore`, the `.aiexclude` directive preempts `.gitignore` directives.\n\nAn `.aiexclude` file follows the same syntax as a `.gitignore` file.\n\nExamples\n\nThe following examples demonstrate how you can configure an `.aiexclude` file:\n\n- Block all files named `apikeys.txt` at or below the directory that contains\n the `.aiexclude` file:\n\n apikeys.txt\n\n- Block all files with the `.key` file extension at or below the directory that\n contains the `.aiexclude` file:\n\n *.key\n\n- Block only the `apikeys.txt`file at the same directory as the `.aiexclude`\n file, but not any subdirectories:\n\n /apikeys.txt\n\n- Block all files in the directory `my/sensitive/dir` and all subdirectories.\n The path should be relative to the directory that contains the `.aiexclude`\n file.\n\n my/sensitive/dir/\n\n- Blocks all the files in directory `foo` and its subdirectories except file\n named `bar.txt` in the foo directory.\n\n foo/*\n !foo/bar.txt\n\nControl access to index for code customization\n\nBy default, code customization indexes all the\n\n[supported code files](/gemini-code-assist/docs/code-customization-overview#limitations)\nin your specified repositories.\n\nTo prevent exposure of code that you don't want to be used in the context, you\ncan use branch patterns to\n\n[control access to your index](/gemini-code-assist/docs/code-customization#control_access_to_your_index_using_repository_groups)\nand use a stable branch, such as `main`.\n\nAlternatively, you can also exclude files from the context by\n[creating an `.aiexclude` file](#write_an_aiexclude_file)."]]