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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way to commit and push multiple files to a bitbucket branch using rest API's.

I want to commit and push multiple files of my application to a bitbucket branch using rest API's.

1 answer

0 votes

Hi Sneha,

Does this concern a Bitbucket Cloud repo (hosted on https://bitbucket.org/) or a Bitbucket Server one (self-hosted instance)?

The two products have different API.

In Bitbucket Cloud this is possible, you can do this using the following endpoint:

An example call would be

curl -X POST -u username:password https://api.bitbucket.org/2.0/repositories/repo-owner/repo-slug/src -F message="test commit message" -F branch=feature_branch -F folder1/my_file.txt=@/Users/tboudale/uploaded_file.txt

where
username is the username of the Bitbucket account you are authenticating with
password the password of this account or an app-password
repo-owner is the workspace ID of the workspace this repo belongs to
repo-slug is the repository slug

This command uploads the file /Users/tboudale/uploaded_file.txt from my machine, to branch feature_branch.

This file is placed in the folder named folder1 in that branch and the file in the repo is named my_file.txt (if the folder doesn't exist already, it will get created as well).

If you don't want to place the file in a certain folder, simply omit the part folder1/ and use only the name you'd like this file to have in the repo.

I'm not sure if there is an API endpoint to do the same for Bitbucket Server. Please feel free to let me know if this concerns a Bitbucket Server repo, and I'll reach out to someone from Bitbucket Server support team to assist.

Kind regards,
Theodora

This is for the Bitbucket Server one (self-hosted instance), basically I have a branch checked out on my local machine and want to commit and push all the changed files to that branch on the server.

Hi @Sneha Badera ,

Thank you for your reply.

This is possible via API for Bitbucket Server too with the following endpoint and PUT method:

The documentation also includes an example curl call.

Please feel free to let me know if you need anything further.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,775 views 10 16
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you