mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-23 00:01:24 -07:00
2.6 KiB
2.6 KiB
name, description
| name | description |
|---|---|
| git-worktree | Manage Git Worktrees according to the "Base Folder Strategy". Use when the user wants to create branches, switch tasks, check out PRs, or manage parallel development environments. |
Git Worktree
Overview
This skill manages the Git Worktree "Base Folder" strategy, ensuring that all functional work occurs in sibling sub-directories (e.g., main/, feature-name/) rather than nested branches. It prevents sandbox interference and enables parallel development.
Core Rules
- Enforced Hierarchy: New tasks or branches MUST be created as sibling directories to
main/. - No Nesting: Branches should never be created inside existing sub-folders.
- Metadata Pathing: When operating in a worktree, always include the primary
main/.gitpath in the trusted environment to bypass macOS sandbox restrictions.
Workflows
1. Creating a New Task (Branch)
When the user asks to "start a new task" or "create a branch":
- Identify the base directory (the parent of
main/). - Use
git worktree add ../<branch-name> -b <branch-name>from withinmain/. - Mandatory Prep: Run
npm installinside the new worktree directory to ensure all dependencies are resolved. - Instruct the user to move into the new directory and reload their session.
2. Checking out a PR (Semantic Naming)
When the user asks to "check out PR #123":
- NEVER use standard
gh pr checkoutwithout a directory. - ALWAYS use the automation script:
./packages/extensions/extension/skills/git-worktree/scripts/worktree-manager.sh pr 123. - Mandatory Prep: Run
npm installinside the new worktree directory to ensure all dependencies are resolved. - This script will automatically fetch the PR title and create a semantic directory name (e.g.,
pr-123-fix-core-bug).
3. Committing Changes in a Worktree
If operating in a sibling worktree (e.g., feature-xyz/):
- Check for sandbox access to
../main/.git. - If access is denied, use
/directory add ../main/.git(if interactive) or suggest the--include-directoriesflag for the next launch.
Task-Based Guide
Managing Worktrees
- List Worktrees: Run
git worktree list. - Semantic PR Checkout:
worktree-manager.sh pr <number>. - Add Manual Worktree:
git worktree add ../<dir> <branch>. - Remove Worktree:
git worktree remove <dir>.
Resources
references/architecture.md
Technical details of the "Base Folder" standard.
scripts/worktree-manager.sh
Automated wrapper for Git Worktree operations that handles sibling pathing, semantic PR naming, and metadata links.