Search @ cannot search from directories excluded by .gitignore

Open 💬 35 comments Opened Aug 30, 2025 by LucasChenZQ
💡 Likely answer: A maintainer (guidedways, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.25.0

Which model were you using?

gpt-5

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

In VS Code IDE plugin, when typing @ to search a file, only files tracked by git can be searched.

The problem is, in many situations I need to wrote scripts, temp function or handling some sample data. Those related files are not supposed to be tracked by git. I usually put them in a git ignored directory, such as playground/, .local/, temp/ .

If it's about security & privacy issue, would it be designed to read git ignored files only when it's commanded?

What is the expected behavior?

Allow @ files even it's not tracked by git.

What do you see instead?

@ action cannot search git ignored files

Additional information

_No response_

View original on GitHub ↗

35 Comments

guidedways contributor · 10 months ago

+1 would like the same, or at least a way to configure this. I add a lot of things to .gitignore (such as certain type of .md files) but want to be able to refer to them as these include instructions for an ongoing task.

efengshan · 10 months ago

I come across the same question, have you solved this problem?

xianghongai · 10 months ago
docs.local/         
└─ Feature.md  

Documentation is ignored in Git, but is needed in AI.

efengshan · 9 months ago

so I wonder have they solved this problem?

kaushikgopal · 9 months ago

quick note on this: it was sort of a head scratcher for me too until i realized the behavior from https://github.com/openai/codex/pull/206 ; i previously maintained a gitignore in my home directory (dotfiles) and set it up in a way where it would ignore all files by default and i would selectively invert the ignore to pick the files I wanted in my repo.

This had the effect where any repository under ~ would effectively fail to @ mention a file within codex cli, unless it got through that directory .gitinore and the parent .gitignore as it traversed up the home directory.

i fixed my issue by just not having a .gitignore in the parent directory but this behavior is unique to codex cli (other solutions seem to not run into this problem, probably because they only respect .gitignore in current directory and nested ones vs. traversing up the directory tree).

CarlosCommits · 8 months ago

bump

kaushikgopal · 8 months ago
bump

@CarlosCommits can you elaborate with a little more effort, what specific issue you're running into? have you tried the workarounds suggested above? what does your current setup look like. a little more info will help provide more insight to the codex team when they look at this issue. As a start, you can try to answer the same questions that LucasChenZQ did at the start of this thread.

CarlosCommits · 8 months ago

@kaushikgopal there's nothing to elaborate? I'm just saying bump to try to get more attention on this issue. This issue is that Codex currently does not let you @ mention any files that are .gitignored.

Molunerfinn · 6 months ago

Need too

jonaswaller · 6 months ago

bump

dheerajawale-svg · 6 months ago

This is issue is becoming bottleneck for me to continue with codex :(

credo-quia-absurdum · 5 months ago

bump

cryptochrome · 5 months ago

How is this still not a thing, half a year later? This should be configurable.

nk-tedo-001 · 5 months ago

bump and sunscribe

dheerajawale-svg · 5 months ago

I think this might need integration with VS Code APIs. If you see Google antigravity, they are able to mention .gitignore files, mostly because their agent integration with underlying vs code fork.

danielpiva · 5 months ago

Any updates on this? Are PRs welcome?

dheerajawale-svg · 5 months ago
Any updates on this? Are PRs welcome?

Doesn't look like it. I am also waiting for it.

ivanjuras · 5 months ago

This is desperately needed. Now i have to do LLM shenanigans and customize workflows just to go around this. Can anyone from OpenAI look into this, please?

wittywolk · 4 months ago

This needs to be configurable.

guytros · 4 months ago

+1

billalelhachlaf · 4 months ago

+1

Light-of-Hers · 4 months ago

I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there.

Most search engines (like ripgrep) prioritize .ignore over .gitignore.

Example .ignore:

!path/to/your/ignored_file.js
!.env

This way, Git still ignores the files, but the agent like codex and opencode can "@" them.

frostme · 4 months ago
I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there. Most search engines (like ripgrep) prioritize .ignore over .gitignore. Example .ignore: `` !path/to/your/ignored_file.js !.env `` This way, Git still ignores the files, but the agent like codex and opencode can "@" them.

@Light-of-Hers this was a great interim work around. While I still want a full solution implemented eventually, this defienitely opened up a lot for me. Especially on a personal project where I needed codex access to ignored *.md files where I was storing my prompts/instructions.Thank you Thank you!

dheerajawale-svg · 4 months ago
I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there. Most search engines (like ripgrep) prioritize .ignore over .gitignore. Example .ignore: `` !path/to/your/ignored_file.js !.env `` This way, Git still ignores the files, but the agent like codex and opencode can "@" them.

Thank you! Works for now

aungsiminhtet · 3 months ago

Another workaround if anyone is interested - in my case I also did not want to bloat the team gitignore with a bunch of personal context files so I built a small CLI called layer that manages git/info/exclude and lets you toggle file visibility on and off. You can unhide files when you need them in the picker, then hide them again before committing. It also keeps local snapshots of those excluded files since agents can quietly overwrite them and there is no git history to recover from. Might be useful until this gets a proper fix.
https://github.com/aungsiminhtet/git-layer

nicoloceneda · 3 months ago

I agree that this issue needs to be solved. Commenting for visibility.

nk-tedo-001 · 2 months ago

bump

hectorddmx-ap · 2 months ago

Adding a concrete variant that is especially painful for pseudo-monorepos / nested repo managers.

Environment:

  • codex-cli 0.121.0
  • macOS 26.4.1, arm64
  • Codex Desktop / @ file mention picker from a root workspace

Setup:

root-repo/
  .git/
  .gitignore
  .meta                # repo manager config listing child repos
  services/
    api/.git/          # independent child repo
    web/.git/          # independent child repo

The root .gitignore intentionally ignores the child repo containers so the root repo does not track embedded repos:

services/

Expected behavior:

  • When Codex is opened at root-repo, the @ picker should be able to mention files from independently managed nested git repos, or there should be a config setting to include specific ignored directories for mentions, e.g. services/api/**.
  • This is distinct from wanting to include arbitrary ignored secrets/build output. These child repos are real working trees with their own .gitignore, tracked files, and agent instructions.

Actual behavior:

  • The root @ picker does not surface files under the child repos because the parent .gitignore ignores the container directory.
  • The agent can still read the files if explicitly given paths or via shell search, so the issue is specifically file mention autocomplete/discovery.

Why this matters:

  • Repo-manager setups such as .meta/pseudo-monorepos commonly keep many independent repos under one operational root.
  • Removing the parent ignore is not a good workaround because the root repo then sees all child repos as untracked directories.
  • Opening Codex separately in each child repo loses the root orchestration context.

A useful fix would be a repo/workspace config option for @ mentions, such as explicit include globs that override parent .gitignore only for mention discovery, while still keeping default ignore behavior for secrets and generated artifacts.

navels · 2 months ago
Adding a concrete variant that is especially painful for pseudo-monorepos / nested repo managers. Environment: codex-cli 0.121.0 macOS 26.4.1, arm64 Codex Desktop / @ file mention picker from a root workspace Setup: `` root-repo/ .git/ .gitignore .meta # repo manager config listing child repos services/ api/.git/ # independent child repo web/.git/ # independent child repo ` The root .gitignore intentionally ignores the child repo containers so the root repo does not track embedded repos: services/ Expected behavior: * When Codex is opened at root-repo, the @ picker should be able to mention files from independently managed nested git repos, or there should be a config setting to include specific ignored directories for mentions, e.g. services/api/*. * This is distinct from wanting to include arbitrary ignored secrets/build output. These child repos are real working trees with their own .gitignore, tracked files, and agent instructions. Actual behavior: * The root @ picker does not surface files under the child repos because the parent .gitignore ignores the container directory. * The agent can still read the files if explicitly given paths or via shell search, so the issue is specifically file mention autocomplete/discovery. Why this matters: * Repo-manager setups such as .meta/pseudo-monorepos commonly keep many independent repos under one operational root. * Removing the parent ignore is not a good workaround because the root repo then sees all child repos as untracked directories. * Opening Codex separately in each child repo loses the root orchestration context. A useful fix would be a repo/workspace config option for @ mentions, such as explicit include globs that override parent .gitignore` only for mention discovery, while still keeping default ignore behavior for secrets and generated artifacts.

This is exactly my situation but the .ignore workaround handles it perfectly.

upnorthmedia · 2 months ago

This should, at a minimum, be a setting that can be toggled.

kt-devoss · 2 months ago

@etraut-openai You labeled this issue as an 'Extension', but I think it also applies to TUI and Apps.

rogdex24 · 1 month ago

this is much needed team-codex

carl010010 · 1 month ago
I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there. Most search engines (like ripgrep) prioritize .ignore over .gitignore. Example .ignore: `` !path/to/your/ignored_file.js !.env `` This way, Git still ignores the files, but the agent like codex and opencode can "@" them.

Can confirm that using a .ignore to un-ignore seems to be working for my needs.

khangtruongfe · 1 month ago
> I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there. > Most search engines (like ripgrep) prioritize .ignore over .gitignore. > Example .ignore: > `` > !path/to/your/ignored_file.js > !.env > `` > > > > > > > > > > > > This way, Git still ignores the files, but the agent like codex and opencode can "@" them. Can confirm that using a .ignore to un-ignore seems to be working for my needs.

It's work to me, thank you

ntc2 · 24 days ago

@LucasChenZQ or anyone who can edit the issue description: please note the .ignore workaround in the issue description:

I found a workaround for this. Just creating a .ignore file in your root and "un-ignore" them there. Most search engines (like ripgrep) prioritize .ignore over .gitignore. Example .ignore: `` !path/to/your/ignored_file.js !.env `` This way, Git still ignores the files, but the agent like codex and opencode can "@" them.