Reputation: 2264
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.
Upvotes: 7
Views: 3364
Reputation: 331
I have a gitlab 15.3.1-ce server installed and the admin user can update the default branch name for all new projects.
In your browser go to this link (replace 'myserver.gitlab.com' for your gitlab server name or IP):
http://myserver.gitlab.com/admin/application_settings/repository#js-default-branch-name
for secure configuration use https:
https://myserver.gitlab.com/admin/application_settings/repository#js-default-branch-name
You'll get this view:
Then, in the 'Initial Default Branch Name' field, type a new name (I used 'master') and click the Save Changes button.
Try to create a new project and check that your default branch name is as you set it.
Upvotes: 1
Reputation: 11271
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:
Upvotes: 5