How-to: Steps to create a pull request on Github

I haven’t worked on many open source projects, so my ability to fork a Github project, pull it down, create a branch, push that branch back, and then submit a pull request are weak, at best.

That being said, I’ve done it a few times lately, so I’m getting better at it. Today was a very smooth process, so I thought I’d make these notes while they’re still fresh in my mind.

Back to top


The first thing to do is fork a project on Github. That’s easy to do, just go to the web page for the project, click Fork, then wait while they fork is created. When it’s done you’ll have a new repository in your list of Github repositories.

Back to top


Next, clone your Github project as usual, i.e., git clone <projectName>.

Back to top

Create a branch

Next, cd into that project directory on your local filesystem. First, you can list all of the project branches with this command:

git branch

Then create a new branch. For example, create a new branch named my-improvements, like this:

git branch my-improvements
Back to top

Use that branch

Next, use that branch for your new edits. You do that by switching to it with the git checkout command:

git checkout my-improvements

You can always confirm what branch you’re currently working in with this command:

git branch

Its output should look like this:

* my-improvements

Now make all the edits/corrections/changes you need to make on this branch. Edit files, delete files, add new files and directories, etc.

Back to top

Commit your changes

After you’re finished, add and commit your changes just like you’re working in master:

git add .
git commit -m "added my excellent changes"
Back to top

Push the changes back to Github

Next, push your changes back to Github. To do this, first switch back to the master branch:

git checkout master

Now when you run git branch you should see this output:

$ git branch
* master

Now push the changes back to Github with this command:

git push origin my-improvements
Back to top

Check Github

Now if you refresh your Github project page in your web browser you should see your new branch has been created. For example, for a simple project you should see that the number of branches has been increased from 1 to 2.

Back to top

Your pull request (PR)

A nice thing about Github is that to submit your pull request, all you have to do is click on the “2 branches” link. This page will show your branches, along with a “New Pull Request” button next to your my-improvements branch. Just click that button, fill out the form, and submit your pull request.

I don’t remember what I did in some previous efforts — though I remember following some Github “help” pages — but this was pretty simple today.

Back to top

Summary: Creating a pull request on Github

If you ever need to create a pull request on Github, I hope these notes are helpful. In summary, the steps are:

  • Fork the project you want to contribute to
  • Clone that new project from your Github repo to your computer
  • cd into that project
  • Create a new branch with git branch my-improvements
  • Use that branch with git checkout my-improvements
  • Make all the changes you want
  • When you’re finished, use git add . and git commit as usual
  • Switch back to master with git checkout master
  • Push the changes back to Github with git push origin my-improvements
  • Go back to the Github page for your repo, and refresh the page
  • Click the “2 branches” link
  • Click the “create a pull request” button and fill out the form

Again, if you need to create a pull request on Github, I hope this is helpful.

Back to top

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.