Skip to content

[Feature Request] Add local-only mode for .codegraph/.gitignore #910

@jadchene

Description

@jadchene

Summary

Currently, CodeGraph generates .codegraph/.gitignore like this:

*
!.gitignore

This ignores all files inside .codegraph/, but intentionally keeps .codegraph/.gitignore visible to Git.

That behavior makes sense when a project wants to commit this file and share the CodeGraph ignore rule with the whole team. However, in many cases CodeGraph is only used by one developer locally. In that scenario, keeping .codegraph/.gitignore unignored creates an extra untracked file:

.codegraph/.gitignore

As a result, the user has to either commit a CodeGraph-specific file, manually edit the generated .gitignore, or manually add .codegraph/ to the project root .gitignore.

Problem

For users who treat CodeGraph as a local-only indexing/cache tool, the generated .codegraph/.gitignore can be slightly intrusive.

The current generated content:

*
!.gitignore

means .codegraph/.gitignore itself appears in git status unless it is committed.

That creates a few drawbacks:

  1. It requires an extra commit just to silence git status.
  2. It adds a .codegraph/.gitignore file to the repository, even if other teammates do not use CodeGraph.
  3. For projects where CodeGraph is only used by one developer, the committed .codegraph/ directory can look unexpected or unnecessary.
  4. Users may prefer CodeGraph's database and metadata to remain entirely local, with no repository footprint at all.

Proposal

Could CodeGraph support one of the following options?

Option 1: Generate only * in .codegraph/.gitignore

Instead of generating:

*
!.gitignore

generate:

*

This would cause .codegraph/.gitignore to ignore itself as well, making the entire .codegraph/ directory local-only and invisible to git status.

Option 2: Add an init option

For example:

codegraph init --local-only

or:

codegraph init --ignore-self

When this option is used, CodeGraph could generate:

*

instead of:

*
!.gitignore

The current behavior could remain the default for users who want to commit .codegraph/.gitignore and share the ignore rule with the repository.

Expected behavior

When using the proposed local-only mode:

codegraph init --local-only

CodeGraph would generate this file:

*

Then git status would not show .codegraph/ at all.

Expected result:

.codegraph/ never appears in git status
no extra commit is needed
no CodeGraph-specific file appears in the repository
teammates who do not use CodeGraph are not affected

Current workaround

Users can manually replace:

*
!.gitignore

with:

*

or add this to the project root .gitignore:

.codegraph/

However, it would be nicer if CodeGraph supported this directly during initialization.

Why this would help

The current behavior is useful for projects that want to commit a repository-level CodeGraph ignore rule.

A local-only option would make CodeGraph less intrusive for individual developers who only want a local cache/index and do not want any CodeGraph-specific files to appear in the repository.

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