קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Gemini Code Assist תומך בהחרגת קבצים מההקשר שלכם ליצירת קוד, להשלמת קוד, לשינוי קוד ולצ'אט. למשתמשי Enterprise, זה כולל גם התאמה אישית של קוד.
במקרים רבים, יהיו לכם קבצים ספציפיים או ענפים שלמים שלא תרצו לכלול בהקשר.
אפשר להחריג את הקבצים האלה באמצעות קובץ .aiexclude או .gitignore.
הגדרת החרגות של הקשר
בקטע הזה מוסבר איך להגדיר את ההגדרות של קובצי .aiexclude ו.gitignore.
שינוי קובץ .aiexclude לקובץ המועדף
כברירת מחדל, ההחרגה לפי הקשר מוגדרת לשימוש בערך .aiexclude. כדי לשנות את ההגדרה הזו בסביבת הפיתוח המשולבת (IDE):
VS Code
בסרגל הפעילות, לוחצים על הגדרותניהול > הגדרות.
בחלון הגדרות, עוברים אל תוספים > Gemini Code Assist. גוללים עד שמוצאים את קובץ החרגה של הקשר.
בשדה הטקסט, משנים את .aiexclude למיקום הרצוי.
הקובץ המועדף שלכם מוגדר עכשיו כקובץ החרגת ההקשר.
IntelliJ
הגדרת ההגדרות לקבצים .aiexclude ו-.gitignore לא נתמכת ב-IDE של JetBrains.
שינוי החרגת ההקשר של קובץ .gitignore
כברירת מחדל, הקובץ .gitignore מופעל להחרגת הקשר. הקובץ צריך להיות ממוקם בתיקיית העבודה הראשית של Gemini Code Assist. לא יתבצע מיזוג או שילוב של .gitignore קבצים שנמצאים בספריות משנה.
כדי להשבית קובצי .gitignore מהחרגת הקשר:
בסרגל הפעילות, לוחצים על הגדרותניהול > הגדרות.
בחלון הגדרות, עוברים אל תוספים > Gemini Code Assist. גוללים עד שמוצאים את Context Exclusion Gitignore.
מבטלים את הסימון של תיבת הסימון.
האפשרות לציין קבצים ש-Gemini Code Assist צריך להתעלם מהם מושבתת עכשיו עבור קבצי .gitignore.
כתיבת קובץ .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.
foo/*
!foo/bar.txt
שליטה בגישה לאינדקס לצורך התאמה אישית של קוד
כברירת מחדל, התאמה אישית של קוד יוצרת אינדקס של כל קבצי הקוד הנתמכים במאגרים שציינתם.
כדי למנוע חשיפה של קוד שלא רוצים להשתמש בו בהקשר, אפשר להשתמש בתבניות של ענפים כדי לשלוט בגישה לאינדקס ולהשתמש בענף יציב, כמו main.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-08-31 (שעון UTC)."],[[["\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)."]]