Skip to content

Start new projects on a Git main branch - #336

Merged
tnkuehne merged 1 commit into
mainfrom
cli-init-git-main
Nov 23, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
cli-init-git-main

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

widefleet init did not create a Git repository. A plain git init afterwards names the first branch master unless init.defaultBranch is configured (Git 2.53 still does). widefleet deploy saves the main app's source from the local branch main, so it then asks for confirmation in a terminal and fails without one, for example in CI or an agent shell:

You are on local branch master. This deploy updates branch main in Widefleet Git and publishes the code as the main app. Switch to main, or pass --allow-branch-mismatch to confirm this deployment

There is no main to switch to in that repository, so the hint does not help either.

What changes

  • init (crates/platform-cli/src/installation.rs) runs git init --initial-branch=main in the new project, without a commit. A later git init only reinitializes it and keeps main.
    • A project inside an existing Git work tree, such as a monorepo, uses that repository, as deploy already does. No nested repository is created.
    • Without Git, init still creates the project, and deploy initializes the repository as before.
  • Deploy branch error (crates/platform-cli/src/source.rs): when the checkout has no local branch main, the error suggests git branch -m main instead of switching branches.

Tests

  • New unit test: init starts a repository on main, and does not nest one inside an existing repository.
  • cli.test.ts: the branch mismatch test checks the rename hint.
  • cargo clippy -p platform-cli --all-targets -D warnings, cargo test -p platform-cli (63 passed) and RUN_CLI_TESTS=1 vitest run apps/control-plane/tests/cli.test.ts (61 passed).
  • Ran the built CLI from an assembled installation: init my-app prints Initialized a Git repository on branch main, a following git init keeps main, and init inside an existing repository creates no .git.

Documentation: #337 (draft until a CLI release includes this change).

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

New projects start on Git branch main without an initial commit.

  • New projects start on the Git main branch.
  • Deploy explains how to rename a branch when local main is missing.

No actionable issues were found.

Reviews (1) · Last reviewed commit: "Start new projects on a Git main branch" · Reviewed by Greptile

widefleet init now creates the project's Git repository on branch main,
unless the project lies inside an existing repository or Git is missing.
A later plain git init keeps main instead of creating master, so deploy
no longer stops at the branch check.

When the checkout has no local main, the deploy branch error suggests
renaming the branch instead of switching to one that does not exist.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 7c3bf2f Nov 23 2026, 01:05 PM

@tnkuehne
tnkuehne merged commit 6b04ccb into main Nov 23, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the cli-init-git-main branch November 23, 2026 14:14
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