'How can I set the default branch name for all new projects on GitLab?

Note that I am not looking to change it for a specific repo.

I want to change the default branch name per account, so any new created repository will have this as default branch.

Currently the default is 'main', some time ago it was 'master'.

See Set default name for default branch in GitHub for a GitHub equivalent.

I found https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/ which is not mentioning such configuration, so it may be not existing at all.

https://docs.gitlab.com/ee/user/project/repository/branches/default.html has an option for an individual repo ("To update the default branch name for an individual project"), there is option for the entire instance or group ("GitLab administrators can configure").

I see nothing that would allow change for a given user without self-hosting own GitLab instance.



Solution 1:[1]

As of april 2022 I believe this is not possible to configure. They seem to have baked the default branch name into the code.

Hopefully they will soon make this a setting that affects all new projects.

As a workaround I create a new project but do not tick the 'add readme' checkbox. The new project will be initialized without a branch.

Then I create the git project locally how I want it to be, add gitlab as remote and push it.

Seems to work:

default branch name on gitlab after initial push

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1