Skip to content

Root-scope first pull overwrites local config.yaml when the remote tracks it #353

Closed

Description

@runkids

Summary

At git_root: root, config.yaml is machine-local and kept out of the repository by the scope-aware .gitignore (internal/git/scope.go, WriteScopeGitignore). If the remote nevertheless tracks config.yaml (a legacy repo, a manual commit, or a remote created before switching to root scope), the first pull on another machine silently overwrites the local config.yaml with the remote copy.

Git treats ignored files as expendable, so this happens on both first-pull paths in FirstPull (internal/git/info.go):

  • merge (merge --allow-unrelated-histories): succeeds and replaces the ignored local file;
  • reset (pull --force, or a scaffold-only repo): reset --hard replaces it.

The command that triggers it finishes with the already-loaded in-memory config, so nothing looks wrong until the next invocation reads the remote's config.yaml (wrong targets, paths, MCP/plugin/hook settings for this machine).

Reproduction (plain git)

git init -q --bare remote.git
git init -q seed
printf 'remote-config\n' > seed/config.yaml
mkdir -p seed/skills/a && printf '# a\n' > seed/skills/a/SKILL.md
git -C seed add -A && git -C seed commit -qm remote
git -C seed push -q ../remote.git HEAD:main

git init -q local
printf 'config.yaml\n' > local/.gitignore
mkdir local/skills
git -C local add .gitignore && git -C local commit -qm scaffold
printf 'LOCAL-config\n' > local/config.yaml
git -C local remote add origin ../remote.git
git -C local fetch -q origin
git -C local -c merge.ff=false merge -q --allow-unrelated-histories --no-edit origin/main
cat local/config.yaml   # -> remote-config

Expected

A first pull never replaces this machine's config.yaml. Options to consider:

  • refuse the first pull at root scope when the remote tree contains config.yaml, with guidance (untrack it on the remote via push's root-scope safety sweep, then pull); or
  • back up config.yaml before integrating and restore it afterwards, then report that the remote tracks it.

Context

Found while reviewing #352 (first pull keeping files-only local commits). It is pre-existing behavior and was deliberately left out of that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions