Sometimes we may need to fetch Pull-Requests from our remote server so we can test/review them. This can be easily done just adding the following line to your .git/config file.
fetch = +refs/pull-requests/*/from:refs/remotes/REMOTE_NAME/pull-requests/*
Note REMOTE_NAME must be replaced by the remote name you are using (usually upstream or origin)
For instance, having the following configuration:
Server Host: https://server.example.com
Server Port: 7999
User Name: ander.ustarroz
Repository Name: proyecto1.git
This is my default configuration on file: “proyecto1/.git/config”
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "upstream"] url = ssh://ander.ustarroz@server.example.com:7999/HW/proyecto1.git fetch = +refs/heads/*:refs/remotes/upstream/* [remote "origin"] url = ssh://ander.ustarroz@server.example.com:7999/~ander.ustarroz/proyecto1.git fetch = +refs/heads/*:refs/remotes/origin/*
In order to be able to fetch the Pull-Requests from the upstream and origin we just need to add the following lines:
For upstream:
fetch = +refs/pull-requests/*/from:refs/remotes/upstream/pull-requests/*
For Origin:
fetch = +refs/pull-requests/*/from:refs/remotes/origin/pull-requests/*
This is the resulting config file:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "upstream"] url = ssh://ander.ustarroz@server.example.com:7999/HW/proyecto1.git fetch = +refs/heads/*:refs/remotes/upstream/* fetch = +refs/pull-requests/*/from:refs/remotes/upstream/pull-requests/* [remote "origin"] url = ssh://ander.ustarroz@server.example.com:7999/~ander.ustarroz/proyecto1.git fetch = +refs/heads/*:refs/remotes/origin/* fetch = +refs/pull-requests/*/from:refs/remotes/origin/pull-requests/*
From now on, every time we are fetching upstream or origin, all the Pull-Requests will be included.