2

I have a private repository in BitBucket.

A team member has read access to this repository and has made a pull request to the main repository.

I want to be able to fetch this repo, so I can see the changes on my computer, without merging those changes yet.

After some time on Google I found:

https://confluence.atlassian.com/bbkb/how-to-locally-fetch-and-checkout-a-pull-request-724402529.html

It says to hover over the new repo and the URL is shown below. However, the URL does not show on my browser. UPDATE: Note that I do not have any permissions to access this repository directly!

Therefore, my question is how can I fetch a repository from a pull request without merging it to my main repo.

Info in how to do this in SourceTree GUI will also be helpful.

Update

Note that git ls-remote origin gives output similar to the following:

$ git ls-remote origin
35xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2d        HEAD
35xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2d        refs/heads/master
36xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/tags/v1.0.0.0
bdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/tags/v2.2.0.0
49xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/tags/v2.2.0.0^{}
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231

3 Answers3

3

You can try

git fetch origin refs/pull-requests/$PR_NO/from:$LOCAL_BRANCH

but there is an open issue that states it's impossible to do what you want.

Found at https://stackoverflow.com/a/40948201/7976758. Recommendation there is to download patch for the PR and apply at manually.

phd
  • 82,685
  • 13
  • 120
  • 165
1

git fetch origin pull/$PR_No/head:$Local_branch

Then;

git checkout $Local_branch to view the remote Pull Request without merging.

Owans
  • 1,037
  • 5
  • 14
-1

Once you can see that branch from your local (by adding a remote, probably) you can checkout that remote branch so you can see if the code is working fine and so on and decide to merge it or not. If you don't like it, then just go back to whatever branch you were on before.

git checkout some-remote/some-branch
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • I don't see the branch. How do I add a remote from a pull request? – Yahya Uddin Jul 24 '17 at 17:30
  • But I'm wondering.... the pull request was against a repo that you aalready have as a remote, I assume, right? Then if should be there after fetching from your already set-up repo (the "main" one, say). – eftshift0 Jul 24 '17 at 17:38
  • The only remotes I have is origin. However this is a pull request. And I can't seem to figure out where I can find this repo on my SourceTree or using Git – Yahya Uddin Jul 24 '17 at 21:40