Error with git init -b main

I am trying to follow the instructions here:

When I do using Ubuntu 20.10, I get the following error.

git init -b main
error: unknown switch `b’
usage: git init [-q | --quiet] [–bare] [–template=] [–shared[=]] []

--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
--object-format <hash>
                      specify the hash algorithm to use

I suspect I need to use --bare, but that makes a main directory in my repository. Maybe I need

git init --bare .

I’m nervous because this is a docs page, and I expect it to be correct.

The Git version 2.27 in Ubuntu 20.10 is a little older and doesn’t support custom initial branch names yet, including the -b option for git init. To get the same effect, you can initialize the repository and then change the branch:

git init
git checkout -b main

Alternatively you could manually install the latest Git version, but as long as this is the worst limitation it’s probably not worth the trouble. Ubuntu 21.04 should have a sufficiently new version. :slightly_smiling_face: