anomalyco / anomalyco/opencode

references: Git branches are not refreshed when an existing reference is attached

Open
#45,562 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 27, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

A configured Git reference is fetched and hard-reset when its reference state materializes or reloads.
Attaching the existing reference with @<alias> later uses the cached checkout without fetching the configured branch first.

If the remote branch advances after initial materialization, the reference can remain stale indefinitely while the location stays active.
The only current refresh paths are unrelated lifecycle events such as a config reload, location-service recreation, or a service restart.

Plugins

oh-my-opencode-slim@2.2.17

OpenCode version

opencode2 v0.0.0-dev-18392
Source revision: 46aa25f236 on v2

Steps to reproduce
  1. Configure a Git reference to a public repository and branch:

    {
      "references": {
        "example": {
          "repository": "<owner>/<repo>",
          "branch": "main"
        }
      }
    }
    
  2. Start or use OpenCode so example materializes.

  3. Advance main in the remote repository.

  4. Without changing the effective OpenCode config or restarting the service, attach @example in the same active project location and inspect a file changed by the newer commit.

  5. The attached reference exposes the cached pre-update revision rather than fetching the newer branch head.

Screenshot and/or share link

N/A

Operating System

Fedora 44

Terminal

kitty

Additional context

There is no git pull or periodic Git-reference polling.
The internal cache uses fetch, checkout, and hard reset when reference materialization occurs.

Expected behavior: attaching a reference that tracks a branch should have a defined freshness guarantee, such as refreshing before it is used or providing an explicit user-visible refresh action/policy.

Workaround: restart opencode2 service, then access the project location again so the reference materializes and refreshes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.