-
Notifications
You must be signed in to change notification settings - Fork 0
Creating good Pull Requests
- Fork project (click upper right "Fork" button on https://github.com/vhf/free-programming-books)
-
Goto your fork, (lower right, SSH clone url) mine is:
[email protected]:borgified/free-programming-books.git
yours will look similar. - Open a Terminal. "git clone" a local copy off your own fork.
git clone [email protected]:borgified/free-programming-books.git
-
Create a branch. You can call it anything, in my example it is "adding_a_book".
git checkout -b adding_a_book
- Make your changes to the file(s) in your newly created branch.
-
Commit your changes.
git commit -a
-
Push your branch to your github repo (which is a fork of vhf/free-programming-books).
git push origin adding_a_book
- Browse to your github repo and click on the green "Compare & pull request"
- 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).
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 your local repo)
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).