Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Hello,

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: http://stackoverflow.com/questions/822811/showing-which-files-have-changed-between-git-branches

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

Thanks

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 https://xxx.com/repo.git
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: https://docs.atlassian.com/bitbucket-server/rest/7.1.3/bitbucket-rest.html

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 bitbucket.org) 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
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

487 views 5 4
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