How to checkout (on a forked repo) a Pull Request coming from the main repo?

How to checkout (on a forked repo) a Pull Request coming from the main repo?

2017, Nov 11    

0. Introduction

By reading the related question on StackOverflow, you can get a very first understanding of today’s topic.

1. Situation

As I mentioned in an earlier post, I am using flexible-jekyll for this blog, which implies that I am working on the forked version of the main project from artemsheludko. So, I have opened an issue on the main project, regarding the possibilities of having post thumbnails for twitter, facebook, etc., which by the way, I find really important. kentonh opened a pull request which seemed to resolve this issue, so I really wanted to test this locally, because I couldn’t wait for at all 😋 🔜

2. Solution

First, we check what we currently have:

first

We then have to add a new entry to map the parent project from Artem:

second

We should be good to go now:

third

Or NOT?

fourth

Of course NOT! Till now, what we have been doing, was only about managing branches. In order to be able to checkout a Pull Request, we have to add the following line, in our .git/config :

fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

So, after that my upstream reference looks like this:

fifth

I should now be able to finally fetch the PR, right?

sixth

Yes, we got it!!! We should be able to check it out using this git command:

git checkout origin/pr/11

Right?

seventh

YES!!!

3. Closing Quote

If it hurts, do it more often.