Skip to content

Share .codegraph index across Git worktrees #1236

Description

@paulo7646

Feature Request: Share .codegraph index across Git worktrees
Summary

It would be very useful if CodeGraph could support sharing a single .codegraph index across multiple Git worktrees belonging to the same repository.

Current behavior

I have a repository organized like this:

Paulo.Lima/
├── .repo/ <-- main repository
│ ├── .git/
│ └── .codegraph/
├── 159340_353/ <-- git worktree
├── 159341_001/ <-- git worktree
└── feature_xyz/ <-- git worktree

The main repository is initialized correctly:

cd .repo
codegraph status

Output:

Project: C:....repo

However, when I enter a worktree:

cd 159340_353
codegraph status

I get:

Project: C:...\159340_353
Not initialized
Run "codegraph init" to initialize

CodeGraph treats every worktree as a completely separate project, requiring its own .codegraph directory and a full index.

Why this is a problem

Large repositories can easily produce multi-gigabyte indexes.

In my case:

~19,800 files
~17,300 Pascal files
~560,000 nodes
Database size around 2 GB

Creating one index per worktree duplicates disk usage, indexing time, and background synchronization, even though all worktrees belong to the same Git repository.

Suggested solution

It would be great if CodeGraph could support one of the following:

Automatically detect Git worktrees and reuse the index from the main repository.
Allow configuring a shared index location (for example via codegraph.json).
Support something like:
codegraph init --shared

or

{
"indexPath": "C:/path/to/shared/.codegraph"
}

This would make CodeGraph much more efficient for developers who rely heavily on git worktree.

Thanks for the excellent project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions