Summary
gbrain sync --repo <path> exits 0 with output Already up to date. when the target path's git working tree is in detached HEAD state. New files in that path are never ingested. The underlying git pull --ff-only failure is logged as a warning, but no error surfaces to the caller — making this very confusing to debug.
Repro
# Set up a worktree in detached HEAD state
git worktree add /tmp/brain-detached <commit-sha> # detached
echo "test content" > /tmp/brain-detached/test.md
# Try to sync
gbrain sync --repo /tmp/brain-detached --source my-source
Observed output
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
Warning: git pull failed: Command failed: git -C /tmp/brain-detached pull --ff-only
You are not currently
Already up to date.
Exit code 0. gbrain.get_ingest_log shows zero new entries. The new file is never ingested.
Expected
One of the following:
- (a) Hard-fail when
git pull fails so callers see the error and exit non-zero
- (b) Detect detached HEAD upfront, skip the pull, and still ingest local-only changes from the working tree
- (c) Print "Sync skipped — worktree in detached HEAD" and exit non-zero, instead of "Already up to date."
Why this happens in real workflows
This isn't an exotic state. The gstack gstack-brain-sync helper creates a worktree at ~/.gstack-brain-worktree for federation; if the user's main worktree (~/.gstack) is on main, the brain worktree gets stuck in detached HEAD because git won't let two worktrees check out the same branch. Every subsequent manual gbrain sync --repo <worktree> silently no-ops without warning the user.
Environment
- gbrain v0.27.0
- macOS 25.4.0 (arm64)
- Bun 1.x
- Reproduced in production federation setup
Summary
gbrain sync --repo <path>exits 0 with outputAlready up to date.when the target path's git working tree is in detached HEAD state. New files in that path are never ingested. The underlyinggit pull --ff-onlyfailure is logged as a warning, but no error surfaces to the caller — making this very confusing to debug.Repro
Observed output
Exit code
0.gbrain.get_ingest_logshows zero new entries. The new file is never ingested.Expected
One of the following:
git pullfails so callers see the error and exit non-zeroWhy this happens in real workflows
This isn't an exotic state. The gstack
gstack-brain-synchelper creates a worktree at~/.gstack-brain-worktreefor federation; if the user's main worktree (~/.gstack) is onmain, the brain worktree gets stuck in detached HEAD because git won't let two worktrees check out the same branch. Every subsequent manualgbrain sync --repo <worktree>silently no-ops without warning the user.Environment