Skip to content

Handle empty repositories when remote HEAD/default branch is unknown #65

Description

@sven1103-agent

Summary

worktree_prepare and auto-provisioned write flows can fail in repositories that have no commits yet.

In that state, remote/default-branch detection can resolve to "(unknown)", and the plugin later tries to fetch or use that as a real ref, which produces:

  • fatal: couldn't find remote ref (unknown)

Current behavior

When the repository is still empty and no branch exists remotely yet, default-branch detection may surface (unknown) from git remote show <remote>.

The plugin currently treats that as a valid branch name and continues into base-target resolution, which then tries to fetch or use (unknown) as the base ref.

Expected behavior

Empty repositories should be handled explicitly.

Acceptable outcomes include:

  • detect the empty or unborn repo state and return a clear, actionable error
  • or skip remote base resolution until an initial commit or default branch exists
  • but do not treat (unknown) as a valid branch or ref

Why this matters

This blocks worktree provisioning and contributes to broken plugin-managed write flows during repository bootstrap.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions