Worktrees created from bare repos are not recognized #7608

Open
opened 2026-02-16 18:07:43 -05:00 by yindo · 1 comment
Owner

Originally created by @earlytobed on GitHub (Jan 26, 2026).

Originally assigned to: @rekram1-node on GitHub.

OpenCode resolves the worktree is the parent of git rev-parse --git-common-dir. For bare repos, --git-common-dir returns the bare repo itself, so its parent is not a git repo.

https://github.com/anomalyco/opencode/blob/022265829eca0032d310e0f177d729290eb6f8fa/packages/opencode/src/project/project.ts#L141-L151

This mis-resolves the worktree path makes later git operations run in a non‑repo directory, causing WorktreeNotGitError.

Originally created by @earlytobed on GitHub (Jan 26, 2026). Originally assigned to: @rekram1-node on GitHub. OpenCode resolves the worktree is the parent of `git rev-parse --git-common-dir`. For bare repos, `--git-common-dir` returns the bare repo itself, so its parent is not a git repo. https://github.com/anomalyco/opencode/blob/022265829eca0032d310e0f177d729290eb6f8fa/packages/opencode/src/project/project.ts#L141-L151 This mis-resolves the worktree path makes later git operations run in a non‑repo directory, causing `WorktreeNotGitError`.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 26, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5638: Desktop app: opening multiple git worktrees from the same repo replaces existing project
  • #4656: Executing run command in worktree reports 'file already exists' error
  • #2445: git worktrees and root-directory
  • #7758: external_directory permission triggered for .opencode/state within git worktree
  • #10468: Worktrees doesn't work well on web

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 26, 2026): This issue might be a duplicate of existing issues. Please check: - #5638: Desktop app: opening multiple git worktrees from the same repo replaces existing project - #4656: Executing run command in worktree reports 'file already exists' error - #2445: git worktrees and root-directory - #7758: external_directory permission triggered for .opencode/state within git worktree - #10468: Worktrees doesn't work well on web Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7608