Creating master branch via gitlab api

Hi,

POST api/v3/projects sets the default_branch to null. Not sure whether this is intentional. If so, how can I create a master branch via api ?

I need a source branch for creating other branches & MRs via apis

Hi @selvagsz,

you can use the API to create branches. Please take a look into this documentation about branches API.

@felipe While creating a new branch, what would be the ref branch when there is no master branch available ?

I’ve checked again on this, you’re right, is not possible to create branches through the API on an empty project as the repo is not created by default.

The default branch for a project is now nil (blank) upon creation, and it will set the default branch to whatever branch is pushed first.

So you need to push a branch in order to get it to work.

You can create a master branch by creating a files ( it will generate master)
Here is the documentation:
https://docs.gitlab.com/ee/api/repository_files.html#create-new-file-in-repository