Skip to content

Search @ cannot search from directories excluded by .gitignore #2952

Open

Description

@LucasChenZQ

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

Activity

  1. added
    bug
    on Aug 30, 2025
  2. guidedways commented on Aug 31, 2025

    @guidedways
    Contributor

    +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.

  3. efengshan commented on Sep 20, 2025

    @efengshan

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

  4. xianghongai commented on Sep 22, 2025

    @xianghongai
    docs.local/         
    └─ Feature.md  
    

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

  5. efengshan commented on Sep 26, 2025

    @efengshan

    so I wonder have they solved this problem?

  6. kaushikgopal commented on Oct 17, 2025

    @kaushikgopal

    quick note on this: it was sort of a head scratcher for me too until i realized the behavior from #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).

  7. CarlosCommits commented on Nov 1, 2025

    @CarlosCommits

    bump

  8. kaushikgopal commented on Nov 1, 2025

    @kaushikgopal

    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.

  9. CarlosCommits commented on Nov 1, 2025

    @CarlosCommits

    @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.

  10. added
    extension
    on Nov 16, 2025
  11. Molunerfinn commented on Jan 2, 2026

    @Molunerfinn

    Need too

  12. jonaswaller commented on Jan 16, 2026

    @jonaswaller

    bump

  13. dheerajawale-svg commented on Jan 19, 2026

    @dheerajawale-svg

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

  14. credo-quia-absurdum commented on Jan 26, 2026

    @credo-quia-absurdum

    bump

  15. cryptochrome commented on Jan 26, 2026

    @cryptochrome

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

  16. 12 remaining items

  17. nicoloceneda commented on Apr 4, 2026

    @nicoloceneda

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

  18. nk-tedo-001 commented on Apr 25, 2026

    @nk-tedo-001

    bump

  19. hectorddmx-ap commented on May 8, 2026

    @hectorddmx-ap

    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.

  20. navels commented on May 8, 2026

    @navels

    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.

  21. upnorthmedia commented on May 16, 2026

    @upnorthmedia

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

  22. kt-devoss commented on May 20, 2026

    @kt-devoss

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

  23. rogdex24 commented on Jun 3, 2026

    @rogdex24

    this is much needed team-codex

  24. carl-lowther commented on Jun 4, 2026

    @carl-lowther

    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.

  25. khangtruongfe commented on Jun 19, 2026

    @khangtruongfe

    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

  26. ntc2 commented on Jun 26, 2026

    @ntc2

    @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.

  27. typhoon93 commented on Jul 29, 2026

    @typhoon93

    this is such a weird issue and crazy it has been up for so long, anyone working on this at all?

  28. adrianrm commented on Aug 7, 2026

    @adrianrm

    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 this answer be pinned? This seems to be solve the problem. What I do:

    /.git/info/exclude

    .ignore
    

    /task-descriptions/.gitignore

    *
    

    /.ignore

    !/task-descriptions/
    
  29. skovranek commented on Aug 15, 2026

    @skovranek

    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.

    👍 thanks

  30. naipi11 commented on Aug 18, 2026

    @naipi11

    A working method for the .ignore workaround (keeping files git-ignored while making them searchable via @):

    1. Create a .ignore file in the workspace root.
    2. Un-ignore the parent directory first, then the file:
    !ignored/
    !ignored/target-file.js
    
    1. Leave .gitignore untouched — git still ignores the files, while ripgrep-based search now includes them.

    The key detail: un-ignoring only the file (!ignored/target-file.js) is not enough when the whole parent directory is git-ignored — ripgrep skips the directory before reaching the file rule. Verified locally with ripgrep 15.2.0: with only the file rule the path stays invisible, and adding the directory rule first (!ignored/) makes it searchable while git check-ignore still reports the path ignored. Independent community workaround; not an official OpenAI fix.

  31. martinguenther commented on Sep 10, 2026

    @martinguenther

    The proposed .ignore solution has worked for me too. Here's how Anthropic solved it in Claude Code https://code.claude.com/docs/en/settings-reference#respectgitignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions