How to checkout a forked pull request locally in SourceTree?

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.


I came across your question while looking for a better way of doing this without using the command window.

My current approach is to:

  1. add the fork originating the PR (pull request) as a Remote. This can be done through the settings at Repository -> Repository Settings -> Remote and then clicking 'Add'.
  2. do a fetch to get a list of the branches and
  3. check out the branch of the PR.

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.


I found that Abhishek's answer works just fine!

Here is how i did:

  • Go to the repositories ".git"-folder and open config-file
  • On the "[remote "origin"]-entry, change fetch to: fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
  • Close the repo-tab in SourceTree and open it again.
  • Click on "Fetch" in the toolbar to fetch all PR-branches.

No the PRs is shown as branches:

enter image description here


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/*