summaryrefslogtreecommitdiff
path: root/docs/cli
diff options
context:
space:
mode:
authorKeith Ballinger <[email protected]>2025-06-03 21:40:46 -0700
committerGitHub <[email protected]>2025-06-04 04:40:46 +0000
commitc313762ba06ab1324dccd4c7663038cb56d24e53 (patch)
treedbec46c12a06047ec1b79bfdfe6c8a5dd90a97be /docs/cli
parentd85f09ac5129227932d3d6cf76b6dac36a325655 (diff)
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery. Key Improvements .gitignore File Filtering All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default. Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden. The behavior can be customized via a new fileFiltering section in settings.json, including options for: Turning .gitignore respect on/off. Adding custom ignore patterns. Allowing or excluding build artifacts. Configuration & Documentation Updates settings.json schema extended with fileFiltering options. Documentation updated to explain new filtering controls and usage patterns. Testing New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases. Test coverage ensures .gitignore filtering works as intended across different workflows. Internal Refactoring Core file discovery logic refactored for maintainability and extensibility. Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box. Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'docs/cli')
-rw-r--r--docs/cli/commands.md3
-rw-r--r--docs/cli/configuration.md16
2 files changed, 18 insertions, 1 deletions
diff --git a/docs/cli/commands.md b/docs/cli/commands.md
index a47f643e..0da4802a 100644
--- a/docs/cli/commands.md
+++ b/docs/cli/commands.md
@@ -43,7 +43,7 @@ Slash commands provide meta-level control over the CLI itself. They can typicall
## At Commands (`@`)
-At commands are used to quickly include the content of files or directories as part of your prompt to Gemini.
+At commands are used to quickly include the content of files or directories as part of your prompt to Gemini. These commands now feature git-aware filtering.
- **`@<path_to_file_or_directory>`**
@@ -58,6 +58,7 @@ At commands are used to quickly include the content of files or directories as p
- Spaces in paths should be escaped with a backslash (e.g., `@My\ Documents/file.txt`).
- The command uses the `read_many_files` tool internally. The content is fetched and then prepended or inserted into your query before being sent to the Gemini model.
- The text before and after the `@<path>` part of your query is preserved and sent along with the file content.
+ - **Git-Aware Filtering:** By default, git-ignored files (like `node_modules/`, `dist/`, `.env`, `.git/`) are automatically excluded. This behavior can be configured via the `fileFiltering` settings.
- **File Types:** The command is intended for text-based files. While it might attempt to read any file, binary files or very large files might be skipped or truncated by the underlying `read_many_files` tool to ensure performance and relevance. The tool will typically indicate if files were skipped.
- **Output:** The CLI will show a tool call message indicating that `read_many_files` was used, along with an improved display message detailing the status (e.g., number of files read, total size) and the path(s) that were processed.
diff --git a/docs/cli/configuration.md b/docs/cli/configuration.md
index da5a6bfd..4367e73e 100644
--- a/docs/cli/configuration.md
+++ b/docs/cli/configuration.md
@@ -42,6 +42,22 @@ When you create a `.gemini/settings.json` file for project-specific settings, or
- **Default:** `GEMINI.md`
- **Example:** `"contextFileName": "AGENTS.md"`
+- **`fileFiltering`** (object, optional):
+
+ - **Description:** Controls git-aware file filtering behavior for @ commands and file discovery tools.
+ - **Properties:**
+ - **`respectGitIgnore`** (boolean, default: `true`): Whether to respect .gitignore patterns when discovering files. When enabled, git-ignored files (like `node_modules/`, `dist/`, `.env`) are automatically excluded from @ commands and file listing operations.
+ - **`customIgnorePatterns`** (array of strings, default: `[]`): Additional patterns to ignore beyond git-ignored files. Useful for excluding specific directories or file types.
+ - **`allowBuildArtifacts`** (boolean, default: `false`): Whether to include build artifacts and generated files in file discovery operations.
+ - **Example:**
+ ```json
+ "fileFiltering": {
+ "respectGitIgnore": true,
+ "customIgnorePatterns": ["temp/", "*.log"],
+ "allowBuildArtifacts": false
+ }
+ ```
+
- **`coreTools`** (array of strings, optional):
- **Description:** Allows you to specify a list of core tool names that should be made available to the model. This can be used to restrict or customize the set of built-in tools.
- **Example:** `"coreTools": ["ReadFileTool", "GlobTool", "SearchText"]`.