abhigyanpatwari/GitNexus · warning

gitnexus: --self-commit skipping file(s) with uncommitted ch

Error message

gitnexus: --self-commit skipping file(s) with uncommitted changes from before this analyze run

What it means

With --self-commit, GitNexus auto-commits its generated context files — but only those recorded as clean in the preRunSafety map captured before the analyze run started. Files that already had uncommitted changes are excluded from the auto-commit and listed in this warning, so the tool never sweeps user work-in-progress into an automatic commit.

Source

Thrown at gitnexus/src/storage/git.ts:187

 * above uses `--porcelain`. If `git commit` fails after `git add` already
 * staged the safe files (e.g. missing git identity), the staged files are
 * reset back to unstaged so the user's index isn't silently left mutated.
 * No-ops silently (never throws) when: none of the candidate files exist or
 * are safe, none changed, or any git step fails. Must never fail the
 * surrounding `analyze` run. See #2639.
 */
export const selfCommitContextFiles = (
  repoPath: string,
  candidateFiles: string[],
  preRunSafety: Map<string, boolean>,
): void => {
  const existing = candidateFiles.filter((name) => existsSync(path.join(repoPath, name)));
  if (existing.length === 0) return;

  const safe = existing.filter((name) => preRunSafety.get(name) === true);
  const skippedDirty = existing.filter((name) => preRunSafety.get(name) !== true);
  if (skippedDirty.length > 0) {
    logger.warn(
      { files: skippedDirty },
      'gitnexus: --self-commit skipping file(s) with uncommitted changes from before this analyze run',
    );
  }
  if (safe.length === 0) return;

  try {
    const status = execFileSync('git', ['status', '--porcelain', '--', ...safe], {
      cwd: repoPath,
      stdio: ['ignore', 'pipe', 'ignore'],
      windowsHide: true,
      encoding: 'utf8',
    });
    if (status.trim().length === 0) return; // nothing to commit
  } catch {
    return; // git failed (not a repo, git missing, etc.) — nothing to do
  }

View on GitHub (pinned to 52924ef12c)

Solutions

  1. Review and commit or stash your own changes to those files, then re-run analyze --self-commit
  2. Or commit them manually: the warning only means the tool declined to include them in its commit
  3. Stop hand-editing files managed by --self-commit; keep overrides in files the tool does not claim

Example fix

# before: file dirty from before the run -> skipped with warning
echo '# my note' >> .gitnexus/context.md && gitnexus analyze --self-commit

# after: commit your edit first, then let the tool own subsequent changes
git add .gitnexus/context.md && git commit -m 'chore: context note' && gitnexus analyze --self-commit
Defensive patterns

Strategy: validation

Validate before calling

import { execFileSync } from 'node:child_process';
// Mirror the tool's own precondition before relying on --self-commit:
const dirty = candidateFiles.filter((f) =>
  execFileSync('git', ['status', '--porcelain', '--', f], {
    cwd: repoPath, stdio: ['ignore', 'pipe', 'ignore'],
  }).toString() !== '',
);
if (dirty.length) {
  // --self-commit will skip exactly these files; commit or stash them first.
}

Prevention

When it happens

Trigger: Running gitnexus analyze --self-commit in a repo where one of the candidate context files (those that exist on disk) was already modified before the run: exactly those files are skipped, the still-clean ones are committed as usual.

Common situations: Hand-edited generated context files; a previous analyze killed before its self-commit could finish; leftover merge-conflict edits in generated files.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@52924ef12c (2026-08-20). Data as JSON: /api/errors/533539262ee0c730. Report an issue: GitHub.