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_
35 Comments
+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.mdfiles) but want to be able to refer to them as these include instructions for an ongoing task.I come across the same question, have you solved this problem?
Documentation is ignored in Git, but is needed in AI.
so I wonder have they solved this problem?
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
.gitignorein 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.gitignorein current directory and nested ones vs. traversing up the directory tree).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.
@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.
Need too
bump
This is issue is becoming bottleneck for me to continue with codex :(
bump
How is this still not a thing, half a year later? This should be configurable.
bump and sunscribe
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.
Any updates on this? Are PRs welcome?
Doesn't look like it. I am also waiting for it.
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?
This needs to be configurable.
+1
+1
I found a workaround for this. Just creating a
.ignorefile in your root and "un-ignore" them there.Most search engines (like
ripgrep) prioritize.ignoreover.gitignore.Example
.ignore: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!
Thank you! Works for now
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
I agree that this issue needs to be solved. Commenting for visibility.
bump
Adding a concrete variant that is especially painful for pseudo-monorepos / nested repo managers.
Environment:
@file mention picker from a root workspaceSetup:
The root
.gitignoreintentionally ignores the child repo containers so the root repo does not track embedded repos:Expected behavior:
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/**..gitignore, tracked files, and agent instructions.Actual behavior:
@picker does not surface files under the child repos because the parent.gitignoreignores the container directory.Why this matters:
.meta/pseudo-monorepos commonly keep many independent repos under one operational root.A useful fix would be a repo/workspace config option for
@mentions, such as explicit include globs that override parent.gitignoreonly 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.
This should, at a minimum, be a setting that can be toggled.
@etraut-openai You labeled this issue as an 'Extension', but I think it also applies to TUI and Apps.
this is much needed team-codex
Can confirm that using a .ignore to un-ignore seems to be working for my needs.
It's work to me, thank you
@LucasChenZQ or anyone who can edit the issue description: please note the
.ignoreworkaround in the issue description: