From Github's Using Pull Requests Page
Pull requests let you tell others about changes you've pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.
Pull Requests are commonly used by teams and organizations collaborating using the Shared Repository Model, where everyone shares a single repository and topic branches are used to develop features and isolate changes. Many open source projects on Github use pull requests to manage changes from contributors as they are useful in providing a way to notify project maintainers about changes one has made and in initiating code review and general discussion about a set of changes before being merged into the main branch.
Here's an example pull request from jQuery's github repo.
There are 2 main work flows when dealing with pull requests:
- Pull Request from a forked repository
- Pull Request from a branch within a repository
Here we are going to focus on 2.
First, we will need to create a branch from the latest commit on master. Make sure your repository is up to date first using
git pull origin masterNote: git pull does a git fetch followed by a git merge to update the local repo with the remote repo. For a more detailed explanation, see this stackoverflow post.
To create a branch, use git checkout -b <new-branch-name> [<base-branch-name>], where base-branch-name is optional and defaults to master. I'm going to create a new branch called pull-request-demo from the master branch and push it to github.
git checkout -b pull-request-demo