About | Links | Scripts
Sharing linux/windows scripts and tips

Trying out a pull request

October 06, 2019 — Jesse Harris

You've received a pull request on your repo. Before merging you want to see what it looks like in your code base. Perhaps you will run some manual test or some diffs from the command line here and there.

You can find this information anywhere out there on the web. As always the purpose of this blog is more of a notetaking for me, but the other angle I want to cover is not the exact commands to type (That will be here too), but why you are typing them.

Get setup

You want to start off with a clean local repository. That might mean running a git pull, a git clone or switching to the master branch using git checkout.

I'm checking out a PR for my snapd ebuild repo

What information will you need?

You will need to know the GitHub authors account name and the branch that they are making changes from.

The commands

From here it's easy. Conceptually, we are checking out a local branch to pull the changes into

        # localbranchname is a new branch where we will pull
        #   the PR. It can be named whatever
        # master is the branch we want the new branch to be
        #   based off

        git checkout -b <localbranchname> master
        git pull <githubAddressToUsersFork>.git <branchTheyCommitedTo>

Merge to master

Perhaps your happy with the change. Your very close to being able to merge the PR to your master repo. Here is how you would do that.

  1. checkout your master branch

  2. merge the local branch you created earlier

  3. push changes back up to the remote origin

         git checkout master
         git merge <localbranchname>
         git push origin master

Tags: git, github