gemini-cli - 💡(How to fix) Fix Feature: GEMINI.md context discovery should traverse git submodules [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25658Fetched 2026-04-20 12:15:49
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Root Cause

Parallel to anthropics/claude-code#44884 — same root cause filed for Claude Code. Worth flagging as a cross-vendor pattern: the same hierarchical discovery model breaks on submodules in both tools.

Fix Action

Fix / Workaround

The workarounds today are all bad:

Code Example

project/                       ← parent repo
├── GEMINI.md
└── api/submodule (has .git file)
    └── GEMINI.md
RAW_BUFFERClick to expand / collapse

What would you like to be added?

Make GEMINI.md auto-discovery traverse into git submodules instead of stopping at submodule boundaries.

Today, when you launch gemini from inside a git submodule, the parent repo's GEMINI.md is not picked up — even though the submodule directory is physically nested inside the parent on disk. The reverse is the same: from the parent, GEMINI.md files inside submodules are ignored.

Repro:

project/                       ← parent repo
├── GEMINI.md
└── api/                       ← submodule (has .git file)
    └── GEMINI.md
  • cd project && gemini → loads project/GEMINI.md, ignores project/api/GEMINI.md
  • cd project/api && gemini → loads project/api/GEMINI.md, ignores project/GEMINI.md

The discovery chain breaks at the inner .git file.

Why is this needed?

Common monorepo-with-submodules layout: the parent repo holds ecosystem-wide context (architecture overview, how services talk to each other, shared conventions), and each submodule has its own service-specific context. That parent context is just as relevant when working inside a submodule, and submodule context is just as relevant when working from the parent on a cross-cutting task.

The workarounds today are all bad:

  • Duplicate the parent context into every submodule's GEMINI.md — DRY violation, drifts immediately.
  • Use @import ../GEMINI.md from inside each submodule — works, but it's manual per-submodule, brittle to renames, and inverted (a submodule shouldn't have to know about parent layout).
  • Put ecosystem context in ~/.gemini/GEMINI.md — pollutes global config with one project's stuff and breaks if you work on a second monorepo or switch machines.

The mental model users actually have: GEMINI.md inheritance follows the directory tree. A submodule being a separate git repo is an implementation detail of git — from the user's and the model's perspective, project/api/ is just a folder under project/.

Additional context

Parallel to anthropics/claude-code#44884 — same root cause filed for Claude Code. Worth flagging as a cross-vendor pattern: the same hierarchical discovery model breaks on submodules in both tools.

Also relevant if/when #12345 lands and AGENTS.md becomes a default context filename — the same boundary problem will apply, since it's traversal logic, not filename-specific. Same goes for users on the array form of contextFileName (since #18598): the fix should apply uniformly to every configured name.

Environment: Windows 11, monorepo with 8+ submodules across mixed stacks (Node.js, Next.js, Lua).

extent analysis

TL;DR

Modify the GEMINI.md auto-discovery logic to traverse into git submodules by ignoring the .git file boundary.

Guidance

  • Investigate the current implementation of GEMINI.md auto-discovery to understand how it handles directory traversal and submodule boundaries.
  • Consider modifying the traversal logic to ignore the .git file and continue searching for GEMINI.md files within submodules.
  • Evaluate the impact of this change on the existing use cases and potential edge cases, such as nested submodules or conflicting GEMINI.md files.
  • Review the parallel issue in Claude Code (anthropics/claude-code#44884) to ensure a consistent solution across tools.
  • Test the modified auto-discovery logic with the provided repro steps to ensure it works as expected.

Example

No code snippet is provided as the issue does not contain sufficient implementation details.

Notes

The solution may require changes to the GEMINI.md auto-discovery logic, which could have implications for other features or use cases. It is essential to thoroughly test the modified logic to ensure it works correctly in various scenarios.

Recommendation

Apply a workaround by modifying the GEMINI.md auto-discovery logic to traverse into git submodules, as this will allow for a more seamless user experience and aligns with the expected mental model of GEMINI.md inheritance following the directory tree.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING