Notes on Making a Pull Request

Ok, so I did a test pull request because I wanted to know more about it and how it worked since the biggest thing holding me back right now is actaully implementing a pull request. This Page was immensely helpful in understanding what a pull request is, how it works, why it matters, and how to implement a pull request(PR). NOTE: This assumes that you know the basics of Git/Github, if you’re still have questions on those/want to get more comfortable with them I would suggest This tutorial from GitHub site which is a nice and short 15 minute tutorial/walkthrough. These articles from GitHub also cover a TON of other stuff from setting up a git/github repo to a whole glossary.

NOTE: This post will deal with a PR from a branch within a repository, usually most projects will have you implement a pull request from a forked repository.

First Things First: WTF is a Pull Request?

A pull request is a way of notifying others about changes that you have pushed to a GitHub repository.

GitHub’s Using Pull Requests Page

Why it matters:

Many open source projects, and even internal projects, use GitHub to make changes to code and update the code base. PRs allows project maintainers about changes that have been made, allowing them to review it, and wether or not to accept the changes, or review them/suggest changes, or reject the changes.

Steps to Create a Pull Request

  1. Make sure what we have is up to Date

This means that we have to make sure to pull from the master repository to make sure that everything we have is up to date. We do that with the command from the command line:

git pull origin master

  1. Create a branch

Now we create a branch. The easiest way for me to conceptualize a branch in my mind is by thinking of it as essentially a copy of the main/master repository, but with the branch we want to be able to make changes to it.

We create a branch with:

git checkout -b BRANCHNAMEHERE # creates the branch git push origin BRANCHNAMEHERE # establishes the repo

  1. Make changes to the code on the branch

These changes can be anything from updating the README, adding documentation, changing the way a class or function works, or updating variables names. The work that you do helps.

  1. Commit the changes you have made to the branch

git add

git commit -m “Updating the README for a more clear introduction and instructions”

git push origin BRANCHNAMEHERE

  1. Make a pull request

Go to the repo page on github and click the button (currently in the top left) that says “Pull Request”.

From here you can pick the branch that you want to have merged using the dropdown. You should usually leave it the way it is, unless you’re working from a remote branch in which case you have to make sure that the master/base repo and the branch you are integrating/merging/pull requesting are correct.

  1. Fill out the pull request

Since this is a nice graphical interface we want to add some detail and documentation so that people know what we’re changing in the code base.

For this we want to add a title of what we’re merging that is descriptive/helpful, but also concise. For more detail we use the comment section below that also uses Github flavored Markdown if you want to format your comment(s)/commentary.

  1. Send the Pull Request

Now you need to click on the (currently green) button at the bottom that says “Send pull request”.

  1. Congrats!!!

From here the maintainer will either add comments, merge your request, or (in very rare cases), reject the request.

  1. Clean up

You can choose to remove/delete the branch that you worked on so that your repo doesn’t become full with a ton of forked/branched repos. You also want to make sure that you’re back on your main repo/master branch(or whatever branch you were working on before with):

git checkout master

NOTE: git checkout master is an example you may have a different branch name that you want to change to.

We use the git checkout command because otherwise we may commit changes that we weren’t intending.

Written on September 21, 2016