Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to change the name of the default branch when creating a repo via bitbucket cloud API

Andre Pilakis
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 31, 2023

Hello, I am attempting to create a bitbucket via the bitbucket cloud API as per: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-put

I have been unsuccessful in being able to create a repo with the main branch named "main", rather than "Master". This is the request I am using:

 

curl --request POST \
  --url https://api.bitbucket.org/2.0/repositories/$workspace/$repo_name \
  --header 'Content-Type: application/json' \
  --user $username:$password \
  --data '{
  "is_private":"true",
  "project": {"key": "$key"},
  "mainbranch": {"name": "main", "type": "branch"}
  }'
Yet whenever I create the branch, the main branch is still called master.

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 2, 2023

G'day, @Andre Pilakis and Welcome to Community!

I understand you wish to create a repository with a new default branch via the Create Repository API endpoint. However, I discover that the API endpoint does not support changing the default branch name when creating a new repository. This is only available in the UI.

We do have an existing feature request on this that I highly suggest you Watch and Vote to get an update at:

Update API endpoint to allow changing main branch name

Cheers,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events