Git initial-branch option ignored

For context, I’m still trying to get things setup for git and github to work together well, and I’m getting pretty close.

The problem I’m currently facing is that git uses the master branch, but github uses the main branch. I read a long article about why exactly that is, which was nice, but the recommendation to fix it didn’t help.

The artcle recommended
git init --initial-branch=main

However, that returns:
warning: re-init: ignored --initial-branch=main

I searched for this error online but I didn’t find anything helpful for me.

Any ideas on how to get git to stop ignoring me? Bad git! :slight_smile:

Thanks in advance!

git init won’t delete existing branches if you call it again in an existing repository, that’s a good thing. In general, there’s no reason to call git init in an existing repository. :wink:

In your existing repository you can just rename the branch:

git branch -m master main

For a new repository that init command should work, or you could set the init.defaultBranch option to change what git init does without the parameter.

While I disagree that ignoring user input, especially without explaining why, is a good thing, I appreciate the information.

1 Like

It told you why, though admittedly not very verbosely. :wink: