Skip to content

Push: Fail on fresh side repo when local default branch is master #2

Description

@sirknigget

git-side appears to initialize a fresh side repo using Git’s local default branch, but git-side push always pushes origin main. On systems where the local bare repo starts on master, the first push fails because there is no local main branch yet.

Reproduction

  1. Install git-side v0.3.0
  2. Initialize a fresh side repo in a project:
git-side init --path /some/base/path
  1. Add at least one file:
git-side add CLAUDE.md
  1. Commit:
git-side commit -m "Initial commit"
  1. Add a remote:
git-side remote add origin https://github.com/<user>/<repo>.git
  1. Push:
git-side push

Actual Behavior

Push fails with:

error: src refspec main does not match any
error: failed to push some refs to '<remote>'

In my case, the local side repo was created on master, not main.

Expected Behavior

git-side push should succeed on a freshly initialized side repo, regardless of the local default branch name.

Root Cause

From the source:

  • side repo initialization uses bare git init without forcing a branch name
  • push is hard-coded to origin main

That means init and push can disagree depending on the Git default branch behavior of the local environment.

Suggested Fix

One of these would fix it:

  1. Initialize the side repo explicitly on main
  2. Push the current branch instead of hard-coding main
  3. Detect the branch name dynamically before pushing

Environment

  • git-side: v0.3.0
  • Platform: Linux arm64
  • Observed with a freshly initialized per-project bare side repo

Workaround

I worked around it by renaming the local side repo branch before pushing:

git --git-dir=<side-repo-path> branch -m master main
git --git-dir=<side-repo-path> symbolic-ref HEAD refs/heads/main
git-side push

Metadata

Metadata

Assignees

No one assigned

    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