init: exclude local .codegraph indexes from git#561
Open
Wood-Q wants to merge 1 commit into
Open
Conversation
Add .codegraph/ to the repository-local .git/info/exclude during project initialization so generated CodeGraph indexes do not show up in git status after `codegraph init`. This keeps GitHub/project .gitignore files clean, avoids committing CodeGraph-specific local state, handles nested project roots, and keeps the operation idempotent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatically add newly initialized
.codegraph/directories to the local Git exclude file (.git/info/exclude) duringcodegraph init.Problem
Today, every time a user runs
codegraph init, the generated.codegraph/directory can appear ingit status. In practice, that means users often have to manually add.codegraph/to.gitignoreafter initialization.That is annoying repeated cleanup, and it also creates a product mismatch:
.codegraph/is local generated index state, not source code. Repositories published to GitHub should not need to carry CodeGraph-specific ignore rules just because one developer initialized an index locally. Other users can simply runcodegraph initthemselves.Solution
This PR writes the ignore rule to
.git/info/excludeinstead of the tracked.gitignore.That gives users the desired behavior locally:
.codegraph/no longer appears ingit statusafter init.gitignoreremains untouchedIf the project is not inside a Git worktree, or Git metadata cannot be accessed, initialization still succeeds and the exclude step is skipped.
Tests
.codegraph/to.git/info/excludenpm run buildnpx vitest run __tests__/foundation.test.tsgit diff --check