feat(worktree): add Git worktree support for isolated parallel sessions

Introduces a central Git worktree management system to enable isolated, parallel agent orchestration. This allows running multiple Gemini sessions on different branches within the same repository without file contention.

Key Features:
- Added 'WorktreeService' in @google/gemini-cli-core to manage creation, lifecycle, and cleanup of Git worktrees.
- Implemented smart cleanup logic that detects untracked files and new commits, automatically preserving worktrees with uncommitted work.
- Added '--worktree' (-w) flag to the CLI to launch sessions in fresh, isolated environments.
- Enhanced the session exit experience with detailed status messages and instructions for resuming work in preserved worktrees.
This commit is contained in:
Jerop Kipruto
2026-03-18 13:48:50 -04:00
parent fac3661980
commit 94ce4aba8b
25 changed files with 1159 additions and 8 deletions

View File

@@ -50,6 +50,7 @@ These commands are available within the interactive REPL.
| `--model` | `-m` | string | `auto` | Model to use. See [Model Selection](#model-selection) for available values. |
| `--prompt` | `-p` | string | - | Prompt text. Appended to stdin input if provided. Forces non-interactive mode. |
| `--prompt-interactive` | `-i` | string | - | Execute prompt and continue in interactive mode |
| `--worktree` | `-w` | string | - | Start Gemini in a new git worktree. If no name is provided, one is generated automatically. Requires `experimental.worktrees: true` in settings. |
| `--sandbox` | `-s` | boolean | `false` | Run in a sandboxed environment for safer execution |
| `--approval-mode` | - | string | `default` | Approval mode for tool execution. Choices: `default`, `auto_edit`, `yolo` |
| `--yolo` | `-y` | boolean | `false` | **Deprecated.** Auto-approve all actions. Use `--approval-mode=yolo` instead. |