Is there any way to set the name for the default branch of new repositories?

Hi there,
I renamed all my master branches to main, because that is what a lot of the git systems do nowadays.
But I cannot find any way to set the default name for new repositories. I will always be master. So first thing I have to do is going through the rename process again…

For self-managed instances this can be configured by an administrator: Branches | GitLab

Admin Area > Settings > Repository

Adjust Default initial branch name

2 Likes

Hmm… so not in the cloud version.
What I can do, though, is create a group ‘my default group’. Then I can set the initial branch name there, and create all my new projects in that group.
Would that work?

EDIT: yes, that works. Just tried it.

1 Like

Hey!

I just realize about this and I don’t like. Is there any way you can choose your default branch name as master on gitlab.com? or this has been like that… just unilateral change without taking into account users or even the the git project?

1 Like

@luispuerto yes, see post above, create a group, then set the initial branch at the group to master or whatever you want. Then when you create projects in that group it will have the branch name that you set, so master if that is what you wanted. If you have your own Gitlab instance, then the admin can set the default to master in the server settings which was also mentioned above on how to do this. Personally, it doesn’t matter to me whether it is master, main or something else. But I guess it depends on your personal preferences.

Please also note, github also has main as the default for branches now as well - this is the way git is going in general. Main translates better than master between languages, which is one of the reasons. You can probably google and find out more reasons as to why this change was made.

Hey!

I’m totally aware of the situation, but I’m really baffled that this has been an unilateral change. Git change was to provide the means to users to define their default branch name. Either master, main or steve. Github now allow users to define their default initial branch name too.

To be honest I don’t know if personally care or nor… it’s just that for me is so silly all of these that I’m totally bewilder for the situation. Funny enough I just realized this yesterday because I always create my repos locally first and Git still uses master and the default branch name for the first branch!

Anyhow, my complain here is the lack of choice on this platform to set the default. Either master, main, cat, dog, or garbage.

PS/ I really don’t know where you all live, but I live in Europe, we have been —and still are— in the middle of a pandemic last year and this one, and we could not care less all these clusterf**ks related to race and gender. We have more important problems to face, to be honest.

1 Like

I am a gitlab user, based in Europe. To be honest, not sure why you brought up the race/gender thing. Don’t really understand what that has to do with the change from master to main, so there wasn’t really any need for such a comment.

You can always open an issue here: Issues · GitLab.org / GitLab · GitLab if you want a Gitlab dev to perhaps add functionality to the web interface to make things simpler for you. The branch rename can also be done with normal git commands from the cli - I found an article on this also, when I was searching on how to do it - in addition to what was posted here previously.

Thank you. Finally I can forget the stupidity with main branch

GitHub lets you change the default branch for all new repositories created by my personal account.

Is there no setting like this in GitLab?

Here’s the GitHub personal account setting:

Usually, I just create repos locally first and so my preferences are respected. However, there are times where I must create the repo first on GitLab dot com and this change causes me to have to do a bunch of work to correct it.