# 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 <ntaylormullen@google.com> |
||
---|---|---|
.gcp | ||
.github | ||
.vscode | ||
docs | ||
eslint-rules | ||
packages | ||
scripts | ||
.gitignore | ||
.npmrc | ||
.prettierrc.json | ||
CONTRIBUTING.md | ||
Dockerfile | ||
GEMINI.md | ||
LICENSE | ||
README.md | ||
eslint.config.js | ||
learnings.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
Gemini CLI
This repository contains the Gemini CLI tool.
Quickstart
- Install Node 18+
- Set your API key:
export GEMINI_API_KEY="YOUR_API_KEY"
(Get an API key)
- For future sessions you can add this to your shell's configuration file, or use a
.env
file in your project's hierarchy
- Run with:
npx https://github.com/google-gemini/gemini-cli#early-access
- Enjoy
Examples
Once the CLI is running, you can start interacting with Gemini. Try a simple query:
> How can I build a web app?
Or ask it to perform a task using its tools:
> List files in the current directory.
API Key Setup
The Gemini CLI requires a Gemini API Key. It supports several ways to authenticate with Google's AI services. You'll need to configure one of the following methods:
-
Gemini API Key:
- Obtain your API key from Google AI Studio: https://aistudio.google.com/app/apikey
- Set the
GEMINI_API_KEY
environment variable. You can do this temporarily in your current shell session:
Or add it to yourexport GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
.env
file (in project directory or user home) or shell's configuration file (like~/.bashrc
,~/.zshrc
, or~/.profile
) for persistence:
Replaceecho 'export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"' >> ~/.bashrc # Or your preferred shell config file source ~/.bashrc # Reload the config
"YOUR_GEMINI_API_KEY"
with your actual key.
-
Google API Key (Vertex AI Express Mode):
- This key can be a general Google Cloud API key enabled for the Gemini API or Vertex AI.
- Set the
GOOGLE_API_KEY
andGOOGLE_GENAI_USE_VERTEXAI
environment variables:export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY" export GOOGLE_GENAI_USE_VERTEXAI=true
-
Vertex AI (Project and Location):
- Ensure you have a Google Cloud Project and have enabled the Vertex AI API.
- Set up Application Default Credentials (ADC). For more details, refer to the official Google Cloud ADC documentation:
gcloud auth application-default login
- Set the
GOOGLE_CLOUD_PROJECT
,GOOGLE_CLOUD_LOCATION
, andGOOGLE_GENAI_USE_VERTEXAI
environment variables:export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID" export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION" # e.g., us-central1 export GOOGLE_GENAI_USE_VERTEXAI=true
Next Steps
Congratulations! You've successfully set up and run the Gemini CLI.
- If you're interested in contributing or building from source, check CONTRIBUTING
- Explore the CLI Commands to learn about all available functionalities.
- If you encounter any issues, check the Troubleshooting Guide.
- For more comprehensive documentation, please see the full documentation here.
Gemini APIs
This project leverages the Gemini APIs to provide AI capabilities. For details on the terms of service governing the Gemini API, please refer to the Gemini API Terms of Service.