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