Please help me with the APIs to
Hi, @Asipu Pawankumar! Welcome to the community!
You can run the following request to create a branch using API:
curl https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/refs/branches -s -u username:AppPassword -X POST -H "Content-Type: application/json" -d '{"name" : "{new_branch_name}","target" : {"hash" : "main"}}'
"main" should be the existing branch or commit hash from where you want to create a new branch.
And in order to delete a branch, you can run the following request:
curl --request DELETE -u username:AppPassword https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/refs/branches/{branch_name}
You can access the following links to find these endpoints:
Create a branch:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-repositories-workspace-repo-slug-refs-branches-post
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/refs/branches#post
Delete a branch:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-repositories-workspace-repo-slug-refs-branches-name-delete
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/{workspace}/{repo_slug}/refs/branches/{name}
I hope this helps, but do let me know if you have any questions.
Kind regards,Caroline
.
non cloud , local host bitbucket , how do we create branch ? and merge to master ?
Hi,
What Kind of option needs to be used for creating and deleting branches?
It looks like you're new here. Sign in or register to get started.