The Wayback Machine - http://web.archive.org/web/20201031022346/https://github.com/vercel/next.js/issues/17733
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default branch for create-next-app output to be `main` #17733

Open
kylemh opened this issue Oct 9, 2020 · 5 comments · May be fixed by #17745
Open

Change default branch for create-next-app output to be `main` #17733

kylemh opened this issue Oct 9, 2020 · 5 comments · May be fixed by #17745

Comments

@kylemh
Copy link
Contributor

@kylemh kylemh commented Oct 9, 2020

Feature request

Is your feature request related to a problem? Please describe.

Currently, the generated codebase from npx create-next-app x yields a project named x with git initialized with master as the default branch. To match up with GitHub, it should be main.

@timneutkens
Copy link
Member

@timneutkens timneutkens commented Oct 9, 2020

Sounds great, feel free to send a PR to change this! We currently use git init hence why master is created instead of main.

@sidthesloth92
Copy link

@sidthesloth92 sidthesloth92 commented Oct 9, 2020

@timneutkens Can I work on this one? I'm assuming, this is where I set it to main:

execSync('git init', { stdio: 'ignore' })

@sidthesloth92
Copy link

@sidthesloth92 sidthesloth92 commented Oct 9, 2020

Have created a PR: #17745

@timneutkens
Copy link
Member

@timneutkens timneutkens commented Oct 9, 2020

git init -b main
error: unknown switch `b'
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]

    --template <template-directory>
                          directory from which templates will be used
    --bare                create a bare repository
    --shared[=<permissions>]
                          specify that the git repository is to be shared amongst several users
    -q, --quiet           be quiet
    --separate-git-dir <gitdir>
                          separate git dir from working tree

Looks like git init does not support branch naming. They have introduced a config option for this though:

git config --global init.defaultBranch main

Sounds like we need to create a new branch then delete the old one if it wasn't main already 🤔

@sidthesloth92
Copy link

@sidthesloth92 sidthesloth92 commented Oct 9, 2020

@timneutkens Yes, git init does not support that.. 😕 But however, the branch master does not actually exist initially. The branches get created only when they have at least one commit. Until the branch gets created, the branch only exists in .git/HEAD. So there is no master branch initialized in the repo.

All we have to do is,

git init

git checkout -b main

// now make the commit

In the end, we will have only one branch.

Checkout my PR: https://github.com/vercel/next.js/pull/17745/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.