How do I create a pull request from the command line?

With Gerrit I type "git push origin HEAD:refs/for/master", what's the equivalent for bitbucket?

3 answers

1 accepted

I can't see anything in that link that shows me how to create a pull request from the command line. I have created pull requests in the Bitbucket web-interface, I've downloaded pull requests from the command line, but I've never found a way to create pull requests from the command line.

If you want to create a Pull Request from the command line, you can use the REST API :

curl -s -u USER:PASSWD -X POST -H 'Content-Type: application/json' -d 'JSON_struct_with_data' http://SERVER:PORT/rest/api/1.0/projects/PRJKEY/repos/REPONAME/pull-requests

Check the doc of REST API for the details on the JSON data block.

HTH

 

Ouch! I get a lot of groans about the the arcane Gerrit syntax (git push origin HEAD:refs/for/MAIN) and the above is not an improvement.

I was hoping that there was something no more complicated in terms of syntax, configurations, required tools to be installed, passwords, etc. than Gerrit for creating a Bitbucket pull requests.

There is - the web UI...

I'm up against Gerrit, compared to Gerrit that's just one additional step to get wrong:

 

  1. Create branch
  2. Go to GUI create pull request

 

Instead of:

git push origin HEAD:refs/for/master

 

=> done!

 

 

The best option is probably to use a couple different tools developed for Stash and/or BItBucket Cloud to do this. The REST API should be similar between them (even though their codebases aren't necessarily the same).

See the excellent utilities I came across from this StackOverflow answer.

http://stackoverflow.com/a/15046966

the Attlassian team have stash (ruby): https://bitbucket.org/atlassian/stash-command-line-tools

Zhemao has bitbucket-cli (python): https://bitbucket.org/zhemao/bitbucket-cli

 

You have a broken link: stash is now at https://bitbucket.org/atlassian/bitbucket-server-cli

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

683 views 0 4
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot