How to merge a pull request

How to locally review, edit, and merge a GitHub pull request.


Assume userfoo has sent us a pull request. We want to test their changes locally and possibly make some edits before merging the pull request into our repository.

  1. Create a new temporary branch based on master to test the changes.
git checkout -b <temp-branch-name> master
  1. Download the pull request. We need the url and branch name; we can get these from the GitHub pull request page by clicking the command line instructions link.
git pull https://github.com/userfoo/project.git branch-name
  1. We can now review, test, and edit the changes locally. To merge the edited pull request, first commit our edits to the temporary branch, then:
git checkout master
git merge --no-ff <temp-branch-name>
git push origin master
  1. We can now delete the temporary branch:
git branch -d <temp-branch-name>