Skip to content

Multiple local clones of same repo share one project identity, breaking file change tracking #17940

@oddvalue

Description

@oddvalue

Summary

When you have multiple local clones of the same git repository (same remote origin URL), OpenCode treats them all as a single project. This breaks file change tracking and causes visual issues in the project selector.

Environment

  • OpenCode version: 1.1.53
  • OS: Linux (Ubuntu)
  • Three local clones of the same repo in separate directories:
    • /home/user/Projects/project
    • /home/user/Projects/project-8000
    • /home/user/Projects/project-8080
  • All three have the same git remote: git@github.com:org/repo.git

Problem

OpenCode generates the project ID from the git remote origin URL rather than the local directory path. This means all three clones resolve to the same project ID (e.g. 5ca09febb1b87758aeeb2c8949774a8bbafc6c8f), sharing a single project record and a single snapshot directory.

Consequences

  1. File change tracking breaks — The snapshot git config's worktree can only point to one directory at a time. Whichever clone was opened last overwrites the worktree path, so file changes are not detected in the other clones. In my case, the snapshot pointed to project-8080 while I was working in project-8000, so session file diffs were always empty.

  2. Project selector shows wrong colors — On the project selection screen, each clone initially has a distinct icon color. But once you select any one of them, all three switch to the same color because they share the same project record and icon.color value.

  3. Only one project record exists — There is a single JSON file in ~/.local/share/opencode/storage/project/ for all three directories, with only one worktree value.

Expected Behavior

Each local directory should be treated as a separate project, even if they share the same git remote URL. The project ID should incorporate the local worktree path (or some other disambiguator) so that:

  • Each clone gets its own snapshot directory with the correct worktree path
  • File change tracking works independently in each clone
  • Each clone can have its own icon color and name in the project selector

Workaround

Manually deleting the snapshot directory (~/.local/share/opencode/snapshot/<project_id>) and restarting OpenCode causes it to recreate the snapshot with the correct worktree for the currently active clone — but this only fixes one clone at a time and the underlying identity collision remains.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions