Since some years, one sould not use master as the default branch name any more. I am typically working with main instead, but this has to be configured on every device where I would start a Git Repo. Now I found a device where this was not yet configured, so I learned how to do it.

Via command line interface

Git makes this easy:

1
git config --global init.defaultBranch main

Editing the config file

I sometimes prefer to not use the command line, but directly edit the configuration file where this data is stored. In particular, this helps me learn such stuff and where it belongs. Git’s global configuration is stored in a file called ~/.gitconfig. This is an ini file, which we can easily edit and add the following:

1
2
[init]
    defaultBranch = main