Blog

Changing Git Default Branch Settings

23. 02. 25.

ClaudeTranslated by Claude Opus 4.5

AI-generated content may be inaccurate or misleading.

By default, git is configured to automatically set a branch called master.

However, starting from the Linux kernel, it was decided that the term master should no longer be used, and it's recommended to change it to main.

Anyway, main is now the trend, and it seems like main branch will become the default going forward, so I changed the settings.

Changing main as the Default on GitHub

First, you need to change the default branch setting to main on GitHub.

settings - repositories

image

main - update

However, this only sets main as default for repositories created on GitHub from now on, so repositories already set to master need to be changed individually.

Go to a specific repo's settings - branches

image

Do this for all repos.

I had about 60, so I was able to finish quickly.

Setting main as Default Locally

In git versions 2.28 and later, the init.defaultBranch setting was introduced to change the default branch setting.

Here's how to configure it.

git config --global init.defaultBranch main

The problem is that if you mindlessly ran sudo apt install git on ubuntu or other Debian environments, your git version is likely below 2.28.

This can be upgraded with the following method.

sudo apt purge git
sudo apt autoremove -y

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

So... goodbye?

Published:
Modified:

Previous / Next