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

Fetch the Bitbucket Pull Request to local repository


I would like to fetch the pull request from my Bitbucket project (private repository) to my local git repository to be able to do some tests before merge etc.

So I have tried (according to docs and this QA forum) this request:

$ git fetch origin pull/3/head

However - what can I do when I get those messages:

fatal: Couldn't find remote ref pull/3/head
fatal: The remote end hung up unexpectedly

4 answers

1 accepted

0 votes
Answer accepted

This feature is not supported at this time. It would be reasonable to compare the branches using this suggestion:

Hello, thanks a lot for your answer. Yes, I am able to diff the branches; however it is quite strange for more complicated pull requests and bigger projects from my point of view.

The following worked for me, for checking out a pull request locally:

git fetch origin refs/pull-requests/<pull request number>/from:<new local branch name>

From there, you can do tests, merge this branch into another branch, etc.

Exactly what I needed. Just checkout the new local branch and voila


Not working for me,  I see this error:

$ git fetch origin refs/pull-requests/1/from:test 

fatal: Couldn't find remote ref refs/pull-requests/1/from
Like # people like this

For me also not working

Like JerseyStan likes this
git config remote.origin.url
git branch repo_pr
git fetch origin refs/pull-requests/1/from:repo_pr
git checkout repo_pr

Guys, any update on this? None of the answers worked for me :(

Getting same error as @Chi Fung Wong

Still not working

wrong comment, cant delete

I made this workaround in our build pipeline, it queries the api which triggers the ref creation (same happens if you go to the diff page of the PR).

1. curl --request GET --url $PATH_TO_PR_DIFF > /dev/null

2. git fetch origin refs/pull-requests/PR_NUMBER/from


This works for me on bitbucket datacenter server 7.1.3., api documentation:

Thanks for this!

I still need to figure out how to get it into our pipeline, but it at least helps explain why our pull requests fail their builds.

This is working for me with BitBucket Server v6.4.1

git fetch origin +refs/pull-requests/*/from:refs/remotes/origin/pull-requests/*

Then `git branch -a` shows the branch available to checkout. 


Credit to Örjan Sjöholm

$ git fetch origin +refs/pull-requests/4/from:refs/remotes/origin/pull-requests/4
fatal: couldn't find remote ref refs/pull-requests/4/from
fatal: The remote end hung up unexpectedly

With Bitbucket Cloud this cannot (currently) be done.

Are you using Bitbucket Cloud (ie or Bitbucket Server?

To confirm this for yourself, run `git ls-remote` against a repo with open pull requests. If you have open pull requests and do not see entries for refs/pull-requests or similar in the output from git ls-remote then there are no pull request refs exposed for you to clone.

Like # people like this

What a bummer!!! Why would I use a web interface when I can do it locally??? :-(

Does GitHub support it?

Suggest an answer

Log in or Sign up to answer
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,741 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