Created: 2021-04-12

Set a custom name as default to initialize your git repos

Let's assume that you would like to set name main as default name for your main branches in git.

If you have git >=2.28 installed the it is pretty easy:

git config --global init.defaultBranch main

In git versions <2.28 you have to create a template to use a different name:

mkdir -p ~/.config/git/template
echo 'ref: refs/heads/main' > ~/.config/git/template/HEAD

Thanks to @telegnom's post and @tastytea's reply