See git-init in the docs.

Initialize repo in existing directory

$ mkdir my-app
$ cd my-app
$ git init

Initialize repo in new directory

$ git init my-app
$ cd my-app

Change default branch

Change the default branch for new repos set up with init.

Currently, the Git default is master. You might want to override to main or dev or edge.

Configure globally

$ git config --global init.defaultBranch main

Then review your config:

$ git config --global -e
[init]
        defaultBranch = main

Configure for one repo

Set the default with a flag.

$ git init -b main