What is the URL of a pull request


I simply need to know how I can download a patch or diff for a pull request.

This is to apply it locally on my private clone before accepting the pull request online.

In github this is simply done by adding .diff or .patch to the end of the pull request - Is there not something similar? Or can this be done in another way?

Ideally I would want to do something like this:

wget URL_OF_PULL_REQUEST | git am

6 answers

1 accepted


Sorry for the misunderstanding. You want the raw diff. We are currently building a complete pull request API. Unfortunately it's not been finalized yet and so it cannot be published at this time.

If you want, you can take the current, undocumented and unpublished version for a spin: https://bitbucket.org/api/2.0/repositories/pypy/pypy/pullrequests/

But be aware that this API will most likely change before it's being released and so expect breakage. When we do release the final API, it will be announced on our blog.

Hope this helps, finally. :-D


Hi Mary,

YES! Thank you! :)

So this is what I wanted:

BUT for some odd reason that forwards to something like:

I would therefore suggest that the API does not forward to a different URL, but provide the diff - witout a redirect.

I would also suggest that you add patch as an endpoint

With diff you can use git apply but with patch you can use git am.

Hope this will be improved in the api.

Thanx for your help!

Best Jorn

Hi Mary, thanx for the reply.

I've gone through the two links, but I don't see a convenient way of doing this without having to go through a number of manual steps.

Take the following scenario.

Say we have 2 different git repos.

A. our_system (for the team)

B. our_system (for a developer, and is a branch of A)

A single pull request is made for 1 or more revisions made in B.

In repo A this would be available under a URL something like this:

Before I accept and comitt pull request 1 into repo A, I would want to test run this on my own machine.

I have a unaltered clone of repo A on my machine.

What command could I use to fetch pull request 1, download it to my machine and apply it to my local clone of repo A?

The examples you mentioned does not seem to focus on a pull request but rather on merging in one or more changesets?

I should note that I don't have read permissions on repo B, but I have full permissions on repo A - so I can't just fetch the commits directly from repo B.

I should mention that for github it is very easy to get the diff of a particular pull request. An example from stackoverflow is:

The above would provide everything found in one pull-request and can be applied using git am.

Thanx for any inputs you may give.




You'll want to use git fetch to get the remote --- http://www.git-scm.com/book/en/Git-Basics-Working-with-Remotes explains about fetch and remotes. Then you can merge...if you want a particular commit you might want to look at git cherry pick once you have the remote.



It sounds like you want a pastebin type feature similar to Gist. We don't have that yet. You can add your voice to the issue for this here:


Until this is implemented, you'll need to do this manually. If Bitbucket can't pull a request -- if it is conflicted, it does provide you with the list of commands to excecute -- but it is more than one.


Hi Mary, no I'm not looking for gist ;)

I'm only looking for a simple way to get the content of a pull request as a downloadable patch/diff
Just like you can do in github - without using gist.

The issue would be the same whether I have read permissions on repo B in my example above.

There are no conflicts on the code - but I only want to be able to get the content of a specific pull request.

If you look at the example URLs from github, you'll see what I'm looking for.

Thanx for your help.

this is quite a crucial feature!

Let's say that Dev1 created a pull request for Dev2. How is Dev2 supposed to try that code locally?

In a Github-like scenario, Dev2 would create a local branch related to that pull request...
It seems like it's not possible to do the same thing in Stash?

Thanks in advance,

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
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...

1,760 views 1 5
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