Problem
CodeGraph uses git ls-files under the hood to discover source files, which means it inherently respects .gitignore. Any directory or file matched by .gitignore is invisible to CodeGraph and cannot be indexed.
In many real-world projects, entire directories are gitignored even though they contain valuable source code that an AI agent needs to understand. Common examples:
- A top-level
customer/ directory that contains per-customer customization code
Pods/ in iOS projects (tracked locally but gitignored)
vendor/ in Go projects
- Embedded independent git repos inside a monorepo
Currently, the only workaround is to remove entries from .gitignore (which changes repo semantics) or to initialize a separate CodeGraph instance inside the ignored directory (which creates a fragmented index and requires passing --projectPath everywhere).
Proposed Solution
Support .ignore files (using the same pattern syntax as .gitignore) that act as a local override layer on top of .gitignore. This is a well-established pattern used by tools like ripgrep, fd, ag, and rg:
.gitignore — patterns to ignore (unchanged, respected by CodeGraph as today)
.ignore — patterns to override .gitignore with negation patterns (! prefix)
For example, if .gitignore contains:
And the user creates .ignore with:
Then CodeGraph would include the customer/ directory in its index even though it's gitignored.
How it works (proposed)
- CodeGraph reads
.gitignore as today to get the base exclusion set.
- CodeGraph then reads
.ignore files (if present) from the same locations where .gitignore is checked.
.ignore patterns are applied after .gitignore patterns, so negation patterns (!xxx/) in .ignore can re-include files/directories that .gitignore excluded.
.ignore is gitignored by default (added to tooling's own ignore list) so it doesn't affect repository semantics.
Why this is better than alternatives
| Approach |
Downsides |
Remove entries from .gitignore |
Changes repo behavior for all git commands; commits required |
git add -f |
Modifies the repo permanently; pollutes git tracking |
| Separate CodeGraph instances |
Fragmented index; --projectPath needed everywhere; no cross-repo queries |
.ignore file |
Zero impact on git; local to each developer; well-known pattern from other tools |
Prior art
ripgrep (rg): reads .ignore files as a gitignore-aware ignore layer
fd: reads .ignore files with the same semantics
ag (the silver searcher): supports .ignore files
- Node.js's
glob module: respects .gitignore + .ignore
- Git itself: supports
.gitignore + .git/info/exclude + core.excludesFile (though .ignore is not native to git)
Use case from the reporter
We have a large networking switch firmware project organized as:
root/ (main git repo, customer/ is in .gitignore)
customer/
cus_dlinkg2/ (1075 C source files, independent git repo)
With .ignore support, users could add !customer/ to .ignore at the project root and CodeGraph would index the customer code as part of the main project — no separate init needed, no --projectPath required.
Additional notes
- The
.ignore file should be checked at the project root level (same directory as .gitignore).
- Ensure
.ignore is added to CodeGraph's own built-in exclusion list so it is never indexed itself.
- The parse order should be:
.gitignore → .ignore (applied as overlay).
Problem
CodeGraph uses
git ls-filesunder the hood to discover source files, which means it inherently respects.gitignore. Any directory or file matched by.gitignoreis invisible to CodeGraph and cannot be indexed.In many real-world projects, entire directories are gitignored even though they contain valuable source code that an AI agent needs to understand. Common examples:
customer/directory that contains per-customer customization codePods/in iOS projects (tracked locally but gitignored)vendor/in Go projectsCurrently, the only workaround is to remove entries from
.gitignore(which changes repo semantics) or to initialize a separate CodeGraph instance inside the ignored directory (which creates a fragmented index and requires passing--projectPatheverywhere).Proposed Solution
Support
.ignorefiles (using the same pattern syntax as.gitignore) that act as a local override layer on top of.gitignore. This is a well-established pattern used by tools likeripgrep,fd,ag, andrg:.gitignore— patterns to ignore (unchanged, respected by CodeGraph as today).ignore— patterns to override.gitignorewith negation patterns (!prefix)For example, if
.gitignorecontains:And the user creates
.ignorewith:Then CodeGraph would include the
customer/directory in its index even though it's gitignored.How it works (proposed)
.gitignoreas today to get the base exclusion set..ignorefiles (if present) from the same locations where.gitignoreis checked..ignorepatterns are applied after.gitignorepatterns, so negation patterns (!xxx/) in.ignorecan re-include files/directories that.gitignoreexcluded..ignoreis gitignored by default (added to tooling's own ignore list) so it doesn't affect repository semantics.Why this is better than alternatives
.gitignoregit add -f--projectPathneeded everywhere; no cross-repo queries.ignorefilePrior art
ripgrep(rg): reads.ignorefiles as a gitignore-aware ignore layerfd: reads.ignorefiles with the same semanticsag(the silver searcher): supports.ignorefilesglobmodule: respects.gitignore+.ignore.gitignore+.git/info/exclude+core.excludesFile(though.ignoreis not native to git)Use case from the reporter
We have a large networking switch firmware project organized as:
With
.ignoresupport, users could add!customer/to.ignoreat the project root and CodeGraph would index the customer code as part of the main project — no separate init needed, no--projectPathrequired.Additional notes
.ignorefile should be checked at the project root level (same directory as.gitignore)..ignoreis added to CodeGraph's own built-in exclusion list so it is never indexed itself..gitignore→.ignore(applied as overlay).