Skip to content

Creating good Pull Requests

Fwiffo edited this page Mar 28, 2014 · 2 revisions
  1. Fork project (click upper right "Fork" button on https://github.com/vhf/free-programming-books)
  2. Goto your fork, (lower right, SSH clone url) mine is: [email protected]:borgified/free-programming-books.git yours will look similar. git clone url
  3. Open a Terminal. "git clone" a local copy off your own fork. git clone [email protected]:borgified/free-programming-books.git
  4. Create a branch. You can call it anything, in my example it is "adding_a_book". git checkout -b adding_a_book
  5. Make your changes to the file(s) in your newly created branch.
  6. Commit your changes. git commit -a
  7. Push your branch to your github repo (which is a fork of vhf/free-programming-books). git push origin adding_a_book
  8. Browse to your github repo and click on the green "Compare & pull request" screen shot 2014-02-22 at 10 47 44 pm
  9. After your PR gets accepted you can delete your branch. (A grey button will show up in the closed PR. You can get to it from your Github notifications). screenshot_7

If you mess up, you can delete your branch on Github. git push origin :adding_a_book Then on your local repo, in that same adding_a_book branch, you can make your new changes and do a git commit --amend when you are done. Then finish with Step 7 and 8.

I like to keep the master branch of my Github fork (and my local master branch also) up to date with vhf/free-programming-books so I do the following:

git remote add vhf https://github.com/vhf/free-programming-books.git
git checkout master
git pull vhf master
git push origin master

So let's assume, I had done a clone of vhf/free-programming-books a couple weeks ago but since then, there had been changes committed to the vhf/free-programming-books's master branch. Because of this, both my local repository (in my Terminal) as well as my Github fork of vhf/free-programming-books are both lagging behind by a number of commits. Let's catch up (fast-forward) to where the latest commit of vhf/free-programming-books is before we apply our own changes.

cd free-programming-books (go to your local repo)

git checkout master (make sure you are on master branch)

git pull vhf master (pull changes from vhf and merge them to ours)

git push origin master (push our now updated local repo to your github fork so that it is updated as well

Now that you are completely up to date, you can jump to Step 4 (above). If these steps aren't taken, then @vhf may run into merge conflicts when trying to add your contribution (not as easy as 1 click merge, when there's no conflicts).

Clone this wiki locally