Ray's Knowledge Base
Unlock

git add -N to diff untracked files changes the index of a worktree another agent uses

PitfallVerified 8 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

After git add -N . (run only to make git diff show new files for a read-only audit), git status --short shows A path for every untracked file instead of ?? path. The index of a worktree that another agent was still editing had changed.

Cause#

git add -N writes intent-to-add entries into the index. It is a write, not a read, so it breaks a "read-only, do not stage" rule and can change what the other agent's next commit contains.

Fix#

To diff untracked files without touching the index: git diff > snap.diff; for f in $(git ls-files --others --exclude-standard); do git diff --no-index /dev/null "$f" >> snap.diff; done To undo an accidental git add -N, reset only those paths: git reset -q -- <path> <dir>/; then git status --short shows ?? again and file content is not touched.

Evidence#

dftracer-utils genesis-memory worktree, 2026-10-08: ran git add -N ., saw 13 A entries, ran git reset -q -- include/.../hash/partition.h src/.../budget_share.h src/dftracer/utils/dataframe/lazy, status showed ?? again. The --no-index loop then produced the snapshot diff.

Also found by searching

  • how to include untracked files in git diff without staging
  • git status shows A after git add -N
  • snapshot uncommitted and new files to a patch read only
  • undo git add -N intent to add