/files throws error upon selecting a file if you are in a git worktree #645

Closed
opened 2026-02-16 17:27:42 -05:00 by yindo · 2 comments
Owner

Originally created by @markjaquith on GitHub (Jul 11, 2025).

Originally assigned to: @adamdotdevin on GitHub.

If you are in a git worktree (from a git repo, type git worktree add ../worktree-test && cd ../worktree-test), the /files command will list files, but selecting one will produce an error:

Failed to read file

Notably, in git worktrees, .git is a file, not a directory. If I rename/remove that file, the error goes away, so I would expect that opencode is doing some sort of git repo introspection before reading a file that works on a regular git checkout, but not a git worktree.

Originally created by @markjaquith on GitHub (Jul 11, 2025). Originally assigned to: @adamdotdevin on GitHub. If you are in a git worktree (from a git repo, type `git worktree add ../worktree-test && cd ../worktree-test`), the `/files` command will list files, but selecting one will produce an error: > `Failed to read file` Notably, in git worktrees, `.git` is a file, not a directory. If I rename/remove that file, the error goes away, so I would expect that opencode is doing some sort of git repo introspection before reading a file that works on a regular git checkout, but not a git worktree.
yindo closed this issue 2026-02-16 17:27:42 -05:00
Author
Owner

@adamdotdevin commented on GitHub (Jul 17, 2025):

oh, interesting, @thdxr i hadn't thought about how we handle worktrees; they don't have a .git folder, it's in a sibling directory (typically)

@adamdotdevin commented on GitHub (Jul 17, 2025): oh, interesting, @thdxr i hadn't thought about how we handle worktrees; they don't have a `.git` folder, it's in a sibling directory (typically)
Author
Owner

@ndraiman commented on GitHub (Aug 8, 2025):

Ran into this issue today.
Opened PR: https://github.com/sst/opencode/pull/1706

@ndraiman commented on GitHub (Aug 8, 2025): Ran into this issue today. Opened PR: https://github.com/sst/opencode/pull/1706
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#645