Skip to content

index_repository silently ignores git global core.excludesFile — globally-excluded files are indexed #499

@everclear077

Description

@everclear077

Version

latest (main, as of 2026-06-18)

Platform

macOS (Apple Silicon)

Install channel

GitHub release archive / install.sh / install.ps1

Binary variant

standard

What happened, and what did you expect?

Actual behavior: When indexing a repository, the tool reads only per-directory .gitignore files committed inside the repo. The global exclude file referenced by git config core.excludesFile (e.g. ~/.gitignore_global on macOS/Linux, %USERPROFILE%\.gitignore_global on Windows) is silently ignored.

Files the user has told git to exclude globally — .DS_Store, Thumbs.db, .idea/, *.pyc, __pycache__/, IDE config directories — are fully indexed and appear in the knowledge graph.

Expected behavior: The indexer should honour all three layers of git's --exclude-standard exclude chain:

  1. Per-directory .gitignore files ✓ (works today)
  2. $GIT_DIR/info/exclude (tracked separately in index_repository ignores .git/info/exclude (only .gitignore honored) → indexes excluded worktrees → OOM #489)
  3. Global core.excludesFile (this issue — currently unhandled)

git ls-files --exclude-standard already reads all three layers; the indexer's tree walk should match that behaviour.

Reproduction

  1. Configure a global gitignore and add a pattern:

    git config --global core.excludesFile ~/.gitignore_global
    echo "*.pyc" >> ~/.gitignore_global
    
  2. Create a minimal test repo with a .pyc file not listed in any in-repo .gitignore:

    mkdir /tmp/testrepo && cd /tmp/testrepo && git init
    touch foo.py foo.pyc
    
  3. Index the repo:
    codebase-memory-mcp index_repository '{"project":"/tmp/testrepo"}'

  4. Query for the excluded file:
    codebase-memory-mcp cli search_graph '{"project":"/tmp/testrepo","name_pattern":"foo.pyc"}'

Expected: no results — foo.pyc should be excluded by the global gitignore.
Actual: foo.pyc appears as a graph node — core.excludesFile was not consulted.

Cross-check: git -C /tmp/testrepo ls-files --exclude-standard --others returns nothing for foo.pyc, confirming git itself respects the global exclude file at all three layers.

Logs


Project scale (if relevant)

No response

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions