Skip to content

Worktrees created from bare repos are not recognized #10643

Closed as not planned
Closed as not planned

Description

@earlytobed

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.

const worktree = await $`git rev-parse --git-common-dir`
.quiet()
.nothrow()
.cwd(sandbox)
.text()
.then((x) => {
const dirname = path.dirname(x.trim())
if (dirname === ".") return sandbox
return dirname
})
.catch(() => undefined)

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

Activity

  1. github-actions commented on Jan 26, 2026

    @github-actions
    Contributor

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

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

  2. ben-vargas commented on Mar 9, 2026

    @ben-vargas
    Contributor

    Yeah, I'm having this issue as well. I use bare git worktrees and the opencode desktop app resolution up to the git root makes "projects" unusable for users that use git worktrees a lot to organize code.

    Structure looks like this, and opencode isn't built to handle it and no options to circumvent or turn-off the upwards traversal...

    project-name/                # Project container (NOT a working tree)
    ├── .bare/                   # 🗄️  Bare git repository (the actual Git database)
    ├── .git                     # 🔗 Pointer file directing Git commands to .bare
    ├── main/                    # ✅ Worktree (branch: main)
    ├── feature-auth/            # ✅ Worktree (branch: feature-auth)
    └── hotfix-security/         # ✅ Worktree (branch: hotfix-security)
    
  3. github-actions commented on May 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  4. franciscopower commented on Aug 4, 2026

    @franciscopower

    Can we reopen this issue? It's still a problem in the current version of Opencode (1.0.164) and makes it unusable for me

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions