Locate the section for your stash remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:private/repository.git
Now add the line fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
to this section. Obviously, change the stash url to match your project's URL. It ends up looking like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:private/repository.git
fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
Now fetch all the pull requests:
$ git fetch origin
From stash.internal:private/repository
* [new ref] refs/pull-requests/1000/from -> origin/pull-requests/1000
* [new ref] refs/pull-requests/1001/from -> origin/pull-requests/1001
* [new ref] refs/pull-requests/1002/from -> origin/pull-requests/1002
* [new ref] refs/pull-requests/1003/from -> origin/pull-requests/1003
...
To check out a particular pull request:
$ git checkout pull-requests/1000/from
Branch pull-requests/1000/from set up to track remote branch pull-requests/1000/from from origin.
Switched to a new branch 'pull-requests/1000/from'
Would it be possible to get actual branch name instead of
/1000/from
?