Ignore parent gitignore rules in file search
What version of Codex is running?
codex-cli 0.86.0
What subscription do you have?
Pro
Which model were you using?
gpt-5.2-codex
What platform is your computer?
Darwin 24.6.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
N/A
What issue are you seeing?
The current file search reads .gitignore files from parent directories above the search root. If the user is inside a nested repository that happens to be ignored by a parent repository, the parent .gitignore rules can exclude the entire subtree. In practice, this makes @-based file search return zero results, which is functionally broken.
Consider the following folder and repository structure:
Directory layout:
/home/dev/project
├── .git
├── .gitignore # contains: nested-project/
└── nested-project
├── .git
├── README.md
└── src
├── lib.rs
└── parser
└── mod.rs
Current behavior - typing:
@re→ no matches@src→ no matches@parser→ no matches
---
From a user’s perspective, a nested repository is a distinct project boundary. The most common expectations are:
- The search should respect the repo’s own .gitignore files.
- The search should not be affected by ignores from an unrelated parent repo.
- The search should stay scoped to the current working subdirectory.
Allowing an unrelated parent repo to mask an entire nested project provides no practical benefit. It prevents using file search in exactly the situations where developers are most likely to rely on it (monorepos, vendor checkouts, and nested tools). This is especially harmful because it fails silently: users see empty results rather than a clear warning.
We already apply a similar boundary rule for AGENTS.md resolution: the system stops at the first git root when aggregating instructions. File search should follow the same mental model. The proposed change aligns with that behavior and restores a consistent, predictable UX without expanding scope or weakening ignore rules inside the current repository.
What steps can reproduce the bug?
1) Create a git repo
2) Create a nested git repo
3) Add the nested git repo to the .gitignore of the parent repo
4) Launch codex in the nested repo
5) Observe that no @ search autocompletes
Folder Setup
set -euo pipefail
ROOT="/tmp/codex-file-search-repro"
rm -rf "${ROOT}"
mkdir -p "${ROOT}"
cd "${ROOT}"
# Parent repo
mkdir parent
cd parent
mkdir .git
printf "nested-project/\n" > .gitignore
# Nested repo (ignored by parent)
mkdir -p nested-project/src/parser
mkdir -p nested-project/.git
printf "readme\n" > nested-project/README.md
printf "lib\n" > nested-project/src/lib.rs
printf "mod\n" > nested-project/src/parser/mod.rs
What is the expected behavior?
Directory layout:
/home/dev/project
├── .git
├── .gitignore # contains: nested-project/
└── nested-project
├── .git
├── README.md
└── src
├── lib.rs
└── parser
└── mod.rs
1) cd /home/dev/project/nested-project && codex
2) Type in input box:
@re→ README.md@src→ src/lib.rs@parser→ src/parser/mod.rs
Additional information
There was a PR opened a month ago, but closed due to no associated bug report: https://github.com/openai/codex/pull/7939
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗