Skip to content

Bare repo + worktrees layout is not detected as a git repository #1595

Closed

Description

@ruudk

Version 0.37.0, macOS.

I use a bare repository layout, where the project root holds a bare clone and all worktrees live next to it:

~/www/cosmos/
├── .bare/          # bare clone
├── .git            # file containing "gitdir: ./.bare"
├── feature-a/      # worktree
└── feature-b/      # worktree

When I open this project, only "Work locally" is available. "New worktree" is disabled with "Project source is not a git repository", and "Existing worktree" says "No worktrees in this project yet". There are four worktrees.

The root is a valid git repository, it is just not a work tree:

$ git rev-parse --is-inside-work-tree
false                                     # exit code 0
$ git rev-parse --is-bare-repository
true
$ git rev-parse --git-dir
/Users/me/www/cosmos/.bare
$ git worktree list
/Users/me/www/cosmos/.bare       (bare)
/Users/me/www/cosmos/feature-a   375bb7d [feature-a]
/Users/me/www/cosmos/feature-b   75376c4 [feature-b]

I had a look at the bundled daemon (host-daemon/dist/daemon-bundle.mjs) and the detection seems to be a single helper:

let r = await Nt(["rev-parse", "--is-inside-work-tree"], { cwd: e, allowFailure: true });
return r.exitCode === 0 && Jl(r.stdout) === "true";

All the git gates use it, so a bare root gets isGitRepo: false and the worktree options are disabled. Falling back to --is-inside-git-dir or --git-dir when --is-inside-work-tree is false would cover this layout.

Related: the "Existing worktree" list appears to be built from bb environments rather than from git worktree list --porcelain, so worktrees created outside bb are never offered. There is already a listWorktrees() in the codebase that could feed that list.

The layout is described here:

Activity

  1. added theissue type on Aug 14, 2026
  2. added
    workspaces
    on Aug 18, 2026
  3. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1595.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): packages/host-workspace/src/git.ts detectGitRepo() only checks git rev-parse --is-inside-work-tree, which is false (exit 0) for a bare repo root, so ensureGitRepo/readGitRepositoryState/getCheckoutRef/host.list_branches/createWorktree all treat the bare-clone+worktrees layout as "not a git repository", disabling New worktree in the picker and failing worktree provisioning with not_git_repo.
    • Proposed fix: Split the two notions bb currently conflates in one boolean. In packages/host-workspace/src/git.ts add detectGitRepoKind(cwd) -> "work-tree" | "bare" | "none" via a single git rev-parse --is-inside-work-tree --is-bare-repository; keep detectGitRepo() = work-tree only (workspace semantics for status/diff/commit) and add detectGitSource() = work-tree or bare (source semantics). Use the source variant in readGitRepositoryState (feeds createWorktree), getCheckoutRef, the ref-reading helpers (readDefaultBranch, readDefaultBranchRefs, hasRef, listBranches) and the gate in apps/host-daemon/src/comm…
    • Caveats: The disabled-reason string on 16ceb3a is "New worktrees require a Git repository with at least one commit" (changed by 893a05a / Allow Tasks dispatch without requiring Git #1396), not the v0.37.0 text "Project source is not a git repository" quoted in the issue; the underlying checkout.kind === "unknown" path is identical. The "Existing worktree lists only bb environments" half of the issue is by design and tracked as Support discovered worktrees and continuing existing branches #1624 (feature re…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions