Skip to content

Fix GitHub push into empty repo - #10

Merged
7vignesh merged 1 commit into
mainfrom
fix/github-push-empty-repo
Oct 14, 2026
Merged

7vignesh merged 1 commit into
mainfrom
fix/github-push-empty-repo

Conversation

@7vignesh

Copy link
Copy Markdown
Owner

Problem

Pushing a generated project to a new GitHub repo failed with Git Repository is empty. The repo was created with auto_init: false, then ensureMainBranchExists tried to build a commit from an empty tree, which GitHub rejects on a repo with no initial commit. The repo was created but no files landed.

Fix

  • Create the repo with auto_init: true so an initial commit on main exists.
  • Poll until the main branch is visible (GitHub initializes it asynchronously).
  • When writing a file that already exists (the auto-created README.md), fetch its current blob sha and pass it so the update does not 409.

Testing

  • Typecheck clean.
  • Verified end-to-end against a live repo: all 21 generated files pushed successfully (Prisma schema, Express routes, React pages, Dockerfile, configs).

Pushing to a new repo failed with 'Git Repository is empty' because the repo
was created with auto_init:false and ensureMainBranchExists then tried to
create a commit from an empty tree, which GitHub rejects on a repo with no
initial commit.

Create the repo with auto_init:true so main exists, poll until the branch is
visible, and pass the existing blob sha when overwriting the auto-created
README so the file update does not 409. Verified end-to-end against a live
repo (21 files pushed).
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stackforge-web Ready Ready Preview Oct 14, 2026 9:09pm UTC

@7vignesh
7vignesh merged commit aec3563 into main Oct 14, 2026
3 checks passed
@7vignesh
7vignesh deleted the fix/github-push-empty-repo branch October 14, 2026 21:09

This branch was successfully deployed

1 active deployment
Preview — 091f4db7 Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant