[FEATURE REQUEST] Allow Claude Code to access gitignored files
Resolved 💬 60 comments Opened Aug 4, 2025 by npupko Closed Oct 24, 2025
💡 Likely answer: A maintainer (hackyon-anthropic, collaborator)
responded on this thread — see the highlighted reply below.
Current Behavior
Claude Code currently respects .gitignore files and excludes gitignored files from:
@-mention autocomplete suggestions- General file awareness and reading (unless explicitly requested)
Problem Description
This behavior creates friction for local development workflows where users want to:
- Keep certain files out of version control (private notes, local configs, etc.)
- Still have Claude Code access these files for development assistance
- Avoid committing sensitive or personal files to public repositories
Use Case Example
I maintain a local tasks/ folder with markdown files containing project notes and TODOs. These files are:
- Gitignored to keep them out of the public repository
- Useful for Claude Code to reference when providing development assistance
- Currently inaccessible via
@-mentions, making the workflow cumbersome
Proposed Solution
Introduce a .claudeignore file that works similarly to .gitignore but specifically controls Claude Code's file awareness:
- Override gitignore: Allow patterns like
!tasks/to make gitignored files visible to Claude Code - Additional exclusions: Support standard ignore patterns to exclude files from Claude Code even if they're tracked by git
- Precedence:
.claudeignorerules should take precedence over.gitignorefor Claude Code's file handling
Example .claudeignore configuration:
# Make tasks folder visible to Claude Code despite being gitignored
!tasks/
# Exclude specific files from Claude Code even if tracked by git
*.log
temp/
Alternative Solutions
- Command-line flag:
--include-gitignoredto override gitignore behavior globally - Config file option: Setting in Claude Code's configuration to control gitignore respect
- Environment variable:
CLAUDE_RESPECT_GITIGNORE=falsefor session-based control
Benefits
- Maintains security by keeping sensitive files out of version control
- Improves local development experience with Claude Code
- Provides granular control over file visibility
- Follows familiar patterns (similar to
.gitignoresyntax)
Impact
This would significantly improve the local development workflow for users who need to reference private/local files while keeping them out of version control.
This issue has been re-created, because the initial one has been closed without the solution: https://github.com/anthropics/claude-code/issues/2305
60 Comments
I'd very much like this as well, though I wonder if an allowlist style would be less complicated, ie.,
.gitignore.claudeallow=> Claude will surface
tasks/things in autocomplete and automatically read them as necessary.This way Claude can continue to reference
.gitignorefor ignored files, but then also allow files explicitly allowed in.claudeallowfor use in autocomplete and file discovery / reading.@nicksergeant Yeah, something like this. I think the main concern for everyone is the
specs,tasks,planswhatever the folder with the specifications we don't want to commit and track but need for planning+1
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Update: This issue persists and shows inconsistent behavior
The Anthropic team claimed to have fixed the gitignore issues in #611, #1818, #2336, but they only fixed the dot-prefix (hidden files) issue, NOT the gitignore exclusion problem.
Current State:
Read()but WON'T show them in@autocomplete. This inconsistency is confusing and suggests the restriction is only partially implemented..claudeignoreReal-world Impact:
Developers cannot properly use Claude Code with:
.env.local,.env.development)tasks/,notes/)CLAUDE.local.md)The Ask:
Please don't close this issue without a proper solution. The community has been clear about the need, and the partial fix for dot-files shows you recognize there's a problem. We need either:
.claudeignorefile that overrides gitignore for Claude Code.claude/claude.jsonthat actually works (currently broken per #1373)This has been an issue for 6+ months across multiple reports. The fact that issues keep being closed and recreated shows this is not resolved. Can we please get a proper resolution or at least an explanation of any technical limitations preventing this feature?
Related issues showing the scope of this problem:
Just to add, the opposite problem is real as well - eg. generated code is usually .gitignore'd though visible to developers – but since Claude respects .gitignore, it becomes quite dumb since it can't look up eg. any generated type definitions.
So there's a need to both ignore more and less.
+1 this.
Quite annoying not being able to access a personal specific file I'm using to aid development, just because I'm (properly, as per git etiquette) gitignoring it.
+1
.claude/ file can be @ -mentioned . It would be helpful when Claude Code user can optionally choose the setting files and others being autocompleted or not.
+1
+1
Imagine working on a cli tool which places logs in it's "bin" directory which is gitignored. You want CC to read the log when makeing a propmpt but you can't @reference the file and have to copy and paste the path manually. This is simply about convenience and this request will keep on re-appearing until this is implemented by the CC team. Matter of time really.
+1
If the files you want to ignore are not project specific, you can use global .gitignore. Fortunately Claude is not aware of this file, so it will be able to access files/folders ignored there and git won't show them as changes.
+1
+1
Please make that configurable though.
+1
Please fix this issue
+1
+1
Can people _please_ stop writing "+1" in the comments and click the 👍 in the original description instead?
I don't think an emoji reaction does as well of a job or noting continued interest (can't tell when someone reacted), I also don't think it should be either/or. Do both.
+1
Claude code should have absolutely ZERO interaction with the
.gitignorefile. Period. it's called.gitignorefor a reason. It's for git. Nothing else.A classic example of why this is a TERRIBLE idea is having a
logsfolder.Obviously, this is something that I'd immediately add to
.gitignore. But if I do that, I can't reference a log file. Which is obviously dumb.I also don't agree with a
.claudeignoreor.claudeallow- this creates too much claude guff in a project root & adds unnecessary dev work.You already have over-engineered settings ecosystem that uses scopes. Stick with that.
For projects:
.claude/settings.jsonFor global (eww):
~/.claude.jsonI don't even understand the point of this especially when you have and appear to use~/.claude/settings.jsonthat's not to mention the
.claude/settings.local.jsonthat sometimes appears too. Then you have the .mcp.json in the project root... CLAUDE.md in the project root...IMHO you only need 2 scopes: Project and User/Global (done properly and contained within the
~/.claude/folder, not spamming config rubbish all over a users home directory) and a single config file for each scope. This way, managing and maintaining a single settings schema becomes trivial which makes documentation easier, adds consistency and reduce the likelihood of issues like what's happening here (where logic interactions get missed).Imo the easy solution should be simple:
settings.json: respectGitIgnoreFile: <bool> // Enable-Disable this behavior = everyone's happysettings.json: respectToolPermissions: <bool> // Make claude interactive elements also respect tool permissions. Example: if"deny":["Read(.venv/)"]is an option, then the @ symbol will also not reference files in this folderThe above is probably the simplest solution as it would keep everyone happy without introducing project breaking bugs. Certainly 1 needs to be the way forward for this, defaulting to true.
However it would probably just be easier to add the following to the
settings.json>"claudeIgnore": [...]. You'll have to decide whether you want this 'decoupled behavior' between the interactive terminal mode and the tool permissions systemThis isn't ideal imo though. I strongly disagree with the idea of having a tool that modifies its behavior based on files that it has no business depending on. Might be a hot take but i doubt it.
@hackyon-anthropic dunno if that makes sense but eh. Hopefully will see this changed soon, I'm finding it quite a nuisance
Agreed, having everything Claude centralized in the
.claudefolder would probably be the best experience.And having an option inside the settings to turn the "use .gitignore" feature off would be great.
Supporting this request from a research workflow perspective. As an astrophysics researcher, I encounter this limitation daily with computationally expensive research outputs that are scientifically critical but storage-prohibitive for GitHub. For example, I have a stellar spectral library comprising thousands of flux files across nine chemical abundance grids, which represents months of computational work. These files are .gitignored solely for storage management (they are too large for free GitHub), not for relevance filtering. I need Claude Code to analyse trends across parameters, compare flux distributions between chemical compositions, and validate model outputs. The current behaviour assumes .gitignore = "not important for analysis," which breaks down in research contexts where .gitignore often means "too large for version control" rather than "not relevant." This creates a false choice between bloating repositories with large datasets or hampering AI assistance for our most important research outputs.
Just encountered this problem when my private memory banks carefully excluded from the repository by .gitignore (and pushed to a different private git) are completely ignored by CC. It's a nonsense - what my git workflow has to do with CC at all?
100% agree. This causes a massive headache, and I'm forever committing files to git that I hadn't intended because I had to remove them from .gitignore just to satisfy claude code.
It just seems so obvious how the current system is fundamentally broken for modern development workflows I'm staggered that a solution isn't already in place. I don't even care what sort of solution it is. I just want a solution so that I can use .gitignore just for git and something else for claude,
+1
+1 Probably the biggest pain point for me as i was Claude Code as a pair programmer and not just some agent in the cloud. It needs .claudeignore it can be with .claude.
A somewhat hacky workaround I've come up with is using a
/commitcommand to explicitly unstage any files I don't want to accidently commit but want Claude to see.commit.md
+1 -- settings.json already has section for excluding sensitive files. There is no reason for claude to ignore files listed in
.gitignoreby default, should be opt-in setting at most.Update: we've added the toggle within /config to allow showing all files in the picker including the gitignored ones!:D
Nice! Is that planned for 2.0.26?
Update - we had a public release this morning for v2.0.27 which contained the fix for this issue!
Is there a configuration setting available to set in JSON or with an environment variable?
@karenzhou-ant Is there a way to hide some files and directories along with using this new setting? Such as
.git,node_modules, etc. Because now the search is really slow for some big projectsUPD: Managed to resolve by providing the custom .ripgreprc config with the needed settings. Thanks!
@npupko How did you set this up exactly? Where did you place the .ripgreprc? Did you set these flags somehow in your project?
Thanks for the effort @karenzhou-ant @hackyon-anthropic but this "Respect .gitignore in file picker" toggle is not a finished feature.
The current toggle creates an all-or-nothing situation: either respect ALL .gitignore rules or respect NONE. In practice, this means:
When enabled (default): Legitimately needed gitignored files are invisible, such as:
notes/ordocs/local/- Personal project documentationTODO.md- Personal task tracking.env.local- Local environment overrides you need to referencecoverage/index.html- Test coverage reports you want to checkWhen disabled: The file picker becomes polluted with thousands of irrelevant files from
node_modules,.next,dist,build,.cache, etc. For example:README.mdin codebase requires scrolling through dozens ofnode_modules/*/README.mdfilesThis is not what 99% users of this feature need. What we actually need is selective .gitignore overrides, not a global toggle.
Common use cases:
notes/*.mdbut NOTnode_modules".env.localbut NOT build artifacts"coverage/reports but NOT.nextordist"TODO.mdbut NOT.cache"In its current state, this is a half-backed feature that satisfies nobody.
This issue has already received some suggestions that would solve this problem:
.claudeignorefile - Allow patterns like!tasks/to selectively expose gitignored files.claudeallowfile - Allowlist approach to explicitly permit specific gitignored filesOr something similar that solves the real problem.
Could we get this prioritized for a proper implementation?
I agree with @funkyOne , the current implementation is hacky at best. I've also noticed the degradation in performance when searching for files.
.claudeignorewould be my preferred implementation as it would follow the same conventions as.gitignore, and as a result presumably be easier to implement..claudeignoreis fine provided it's contained insettings.json. Claude spams way too many files. It's time for them to improve their entire settings ecosystem imo. 1 settings file per scope is all that's required.I really don't want to see any more .ignore / .include / etc file 'spam'. There's too much project clutter as it is
That's just your preference. I want a .claudeignore that follows conventions, similar to for example .dockerignore. It's not that uncommon. Keeping everything in one config file is a bad practice. Maybe just move the config files to .claude folder.
Update: we now support users specifying specific files/directorie to ignore using the --no-ignore-vcs flag instead of the --no-ignore flag. that way, users can still put stuff inside a .ignore file and that should be ignored by ripgrep.
@karenzhou-ant great, is there any documentation about it anywhere? Could not find anything in https://docs.claude.com/en/docs/claude-code/cli-reference
@karenzhou-ant , is this configurable only as a flag, or is it configurable by
settings.jsonas well?@luiz00martins @deviantony @funkyOne
This is now configurable through:
/config.ignorefile in the current directory and add the patterns you want ignored in the searchThis is now also supported in the VSCode extension. There's a separate config in the VSCode extension as well (although settings here aren't shared, and you'll need to disable the setting again in VSCode for it to work)
WARNING: Understanding that Claude may pick up on secrets, API tokens, etc in your .gitignored files if you disable the respect gitignore setting, so use this carefully!
Nice stuff!
One minor question: Was
.ignorea typo for.claudeignore, or it that the correct name?Should just be
.ignoreWeird naming choice but thanks for the info!
That is a wierd choice of name, why not .claudeignore? Makes its purpose much clearer and consistent with existing .ignore files.
That said it does work well, thanks for implementing.
Can this be done PURELY within
.claude/settings.json? If so how? I don't want to add .ignore to every projectAny update on this? This feels like a pretty terrible solution if not. I don't want to disable
.gitignoreacross the board, I want to explicitly enable / disable indexing on a per project basis by exception. This approach (seemingly) forces me now to decide between unexpected results in every single project so that I can deal with an exception in one.Is this the intended behaviour?
"Terrible solution" feels like an overstatement. As far as I'm seeing, you could keep the setting enabled globally, and only disable in projects where you have a
.ignorefile set up.However, yes, it'd be nice to have this configurable on
settings.jsoninstead. I feel like it'd give the ability to configure per-project and globally for free (as per the natural of Claude Code'ssettings.json, which can be configured globally, or per project).@luiz00martins perhaps I have misunderstood how this has been implemented then. I understood from what's been documented (and what I tested) that you enable/disable it in
/configsection of Claude Code, whcih means that setting is global.What do you mean by "only disable in projects where you have a .ignore file set up"? How is that possible if this is not configurable in settings.json?
@luiz00martins any final thoughts?
I have a
depsfolder that contains many folders that is updated frequency. Of those, I'd like claude to ignore all but one of them. This pattern worked in.gitignorebut doesn't seem to work in.ignore, with the entire deps folder being ignored.Is this intended behavior? Is there another way of achieving this goal I should try?
@mattheworiordan I now think _I_ may have misunderstood the settings structure.
It was my understanding that every one of the global configurations was present in the root
settings.jsonfor claude. In that case, you would set up your global configuration to true, and every project that has a.ignorefile, you would set up the configuration to false in that project'ssettings.json.However, I have just looked at my
settings.jsonfile, and this setting doesn't seem to be present in there. So I guess I was mistaken.If that's the case, then I also find this solution very unsatisfactory.
开发中
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Just submitted a change to add per-project setting for this one, so you can add
"respectGitignore": falsetosettings.jsonorsettings.local.jsonand have this setting be applied locally. Should be available later in the week!for those who want to ignore everything in a directory except certain exclusions, you can try to add something like this to your
.ignore: