Creating branches using the Bitbucket REST API

This question is in reference to Atlassian Documentation: repository Resource

Is there a way to create a branch in a Bitbucket cloud repository using the REST API? There's a button on the Web UI to do so.. I know I can use git itself to create and push a branch, just wondering if I can do it in our build process without cloning the repo locally first. 

2 answers

it's not the official API docs but I traced the web call from the frontend but this works

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -vv -u '$USERNAME:$PASS' "https://bitbucket.org/branch/create" -s -d 'repository=$TEAMORUSER%2F$REPO&from_branch=master&branch_name=staging'

 

Didn't have any luck with that:

'from_branch' is not recognized as an internal or external command,
operable program or batch file.
'branch_name' is not recognized as an internal or external command,
operable program or batch file.

Worked for me just a few minutes ago. Can you provide the command you're using without your credentials scrubbed?

 

Ergh, apologies, it's working fine.

 

Must have missed a typo the other day.

Any answer on this?  I need to do this as well.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

96 views 3 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you