How-to: Steps to create a Github pull request (git branch, etc.)

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.


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.


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

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

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.

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"

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

When you do this, you’ll see some output like this at the command line:

remote: Create a pull request for 'my-improvements' on GitHub by visiting:

This is nice, because it now gives you the URL to go to where you can complete your pull request.

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.

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 used to follow some convoluted process, but this was much simpler today.

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.