Skip to content

fix(repo): trust init.defaultBranch only for a branch the monorepo has - #529

Draft
roschaefer wants to merge 1 commit into
mainfrom
fix/20-default-branch
Draft

roschaefer wants to merge 1 commit into
mainfrom
fix/20-default-branch

Conversation

@roschaefer

Copy link
Copy Markdown
Owner

Without origin/HEAD, the monorepo's default branch fell back to
init.defaultBranch. That setting names the branch a new repository
starts on, not this repository's default: git init -b main under a
global init.defaultBranch=master gave master. Cloning an upstream
whose default is also master then recorded no default-branch, so the
splice looked for a nonexistent upstream main, and push failed for
lack of a local master.

The fallback now counts only if the monorepo has that branch, locally or
as origin's. Otherwise the default branch is unknown, and clone, init
and the submodule conversion already refuse with a message naming
git config init.defaultBranch and git remote set-head origin --auto.

Fixes #20

Without origin/HEAD, the monorepo's default branch fell back to
init.defaultBranch. That setting names the branch a new repository
starts on, not this repository's default: `git init -b main` under a
global `init.defaultBranch=master` gave `master`. Cloning an upstream
whose default is also `master` then recorded no default-branch, so the
splice looked for a nonexistent upstream `main`, and push failed for
lack of a local `master`.

The fallback now counts only if the monorepo has that branch, locally or
as origin's. Otherwise the default branch is unknown, and clone, init
and the submodule conversion already refuse with a message naming
`git config init.defaultBranch` and `git remote set-head origin --auto`.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ccd6fc6f-7c46-4b49-82e1-66507b3d1b50
Commits

Reviewing files that changed from the base of the PR and between cb3f483 and 1b0e233.

Files selected for processing: 2

  • docs/tests/clone.bats
  • src/repo.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

init.defaultBranch is trusted even when this repository uses another default

1 participant