---
name: Sync script bug — untracked files
description: RESOLVED 2026-05-21 — sync.sh now uses git status --porcelain (catches untracked-only changes) in both repo and vault detection.
type: project
---

> **RESOLVED 2026-05-21.** Fixed in `.claude/scripts/sync.sh`: both the main-repo (Phase 1)
> and vault change-detection now use `if [ -n "$(git status --porcelain)" ]` instead of
> `git diff-index --quiet HEAD --`, so untracked-only changes are caught. A `.gitignore` entry
> was added for the datto BSOD dumps (54 MB binary) so the fix doesn't sweep them in. Original
> report retained below.

`.claude/scripts/sync.sh` line 53 uses `git diff-index --quiet HEAD --` to detect local changes. This only flags **tracked** files with modifications. Brand-new untracked files (a new report, new session log, new memory) will NOT be detected on their own — they only get swept up when a tracked file is also dirty (because `git add -A` then runs).

Symptom seen 2026-04-17 by Howard: added a single new report file, ran /sync, script said "No local changes to commit" and did nothing. Workaround was `git add <file>` first, then re-run.

**Why:** `git diff-index` ignores untracked files by design. Needs `git status --porcelain` (any output = changes) or equivalent.

**How to apply:** Mike — small one-line fix in `.claude/scripts/sync.sh`. Suggested replacement:

```bash
# Before (line 53):
if ! git diff-index --quiet HEAD -- 2>/dev/null; then

# After:
if [ -n "$(git status --porcelain)" ]; then
```

Also applies to the Sync Summary's `git diff --stat $LOCAL_BEFORE..HEAD` — may need review to make sure the summary range still makes sense after the detection fix.
