Setting main branch

We are creating projects programmatically via rest api, see

Unfortunately, this call creates a projects with default branch set to ‘master’, which does not comply with our policies. Is there any option to set the default branch during creation?

e.g. sonarqube seems to support such, see SonarQube

Any help appreciated.



Hey there.

You can rename the branch after the POST api/projects/create call using POST api/project_branches/rename.

Hi Colin,

thank you very much for your help here. But I seem to be a bit lost here. We tried that, but get an error message about the project not existing.

{"errors":[{"msg":"Project doesn\u0027t exist"}]}

As far as I understand, to be able to post a branch rename the user needs the permission to administer the project.

Currently we issued a token for a user who has permissions to create projects. It seems to be the case, that this user has not the administer permission on the newly created project. And, honestly, I am unsure if I’d like that at all, as this would have other implications.

In any case, how would you suggest to proceed here? Is there a way to assign the required permissions to the user for which we issued the token? I am missing something here.

This is true – and there’s no way around it.

Ok. But how could I assign that permission to the user?

It can be assigned both at the project level (project-level Administration > Permissions) and, more desirably, in the permission template that is being applied to new projects.