Reputation: 97717
Sometimes pull requests are quite complex and/or potentially bug-ridden. In that case it can be a little unreasonable to spot check a pull request solely by reading the code. It makes more sense to checkout, pull, and build that pull request locally first before merging it. In this manner a repo maintainer can have more confidence that the pull request didn't introduce any regression issues.
I can checkout a pull request from the command-line fairly easily, but I would prefer to use SourceTree. I know using the command-line is simple and straightforward, but I believe in using GUI tools whenever possible over command-line tools. SourceTree has become the de facto standard gui git client for windows, so it seems like SourceTree would have this basic functionality. However, I tried a number of different commands and dialogs and I can't seem to get access to the pull request inside SourceTree.
Can a pull request be pulled locally just using SourceTree? How?
Upvotes: 10
Views: 7663
Reputation: 31
Bitbucket repos: follow Abhishek's answer but replace the final line with the following:
fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
Upvotes: 3
Reputation: 1640
I found that Abhishek's answer works just fine!
Here is how i did:
"[remote "origin"]
-entry, change fetch to: fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
No the PRs is shown as branches:
Upvotes: 2
Reputation: 325
I came across your question while looking for a better way of doing this without using the command window.
My current approach is to:
It doesn't give direct access to the PR but it does get me a local copy of the changes. I still accept and merge or ask for revisions via github. If the PR changes I just pull the updates into the branch.
Sourcetree appears to view PRs as a means of managing the return of local changes to the origin repo.
Upvotes: 6
Reputation: 302
Change your .git/config
to the following and do a fetch:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:{user}/{repo}.git
+ fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
Upvotes: 11
Reputation: 97
It's not possible the checkout a forked repo on Bitbucket at all.
You have to download a patch and apply to test
# Download the patch file.
curl -u user:password https://bitbucket.org/api/2.0/repositories/{user}/{repo}/pullrequests/{pull_no}/patch -L -o name.patch
# Apply the patch file to your local Git checkout.
git apply name.patch
Upvotes: 0
Reputation: 1
You can fetch the pr branches, and then just treat PRs like any other branch. See https://gist.github.com/piscisaureus/3342247
Basically, all PRs are under refs/pull/*/head
, where all the branches you're usually using are under refs/heads
Upvotes: 0
Reputation: 97717
It is not possible to checkout a pull request from a forked repo directly in SourceTree.
I forwarded this question to the atlassian question and answer board, as well, and the question was answered in a comment.
From what I know there is not a way to do this action within sourcetree directly, as sourcetree is used to work with the git repos that you have locally and not to work with PRs or remote repos that you may have access to in Bitbucket or Github.
Essentially you have to clone the other repo, separately, and switch to whatever branch is being used for the pull request.
Kind of sad this functionality is so easy from the command-line, but is more cumbersome in SourceTree's Gui.
Upvotes: 3