Branches and Pull Requests

Pull requests are essential to any good software development.

To understand what are pull requests and why we use them, we first need to understand the concept of branches.


“A branch is essentially is a unique set of code changes with a unique name. Each repository can have one or more branches. The main branch — the one where all changes eventually get merged back into, and is called master.” Source

Let’s use an example to illustrate why we would need different branches on a particular project.

Let’s say that you are developing the game Flappy Bird. On the master branch, you have the main code that makes the game work. That is the code with which users directly interact. One day, you decide that you want to add new characters to the game, so you code it. You commit to the master branch, and suddenly, you realize that there is a bug in your code. The result? Millions of people who are playing your game suddenly run into your bug that makes the entire app crash.

Not so smart right? Instead of committing your code to the master branch, which is potentially at risk of bugs, one should commit to another branch. Then, this code is reviewed by others through a pull request and merged onto the master branch when approved.

Github Branches

Pull Requests

Pull requests allow us to move code from one branch onto another.

If you are working on an open-source project, and you want strangers to contribute, it wouldn’t be so smart to let them directly commit to the master branch. Pull requests are also extremely helpful in these scenarios.

See Contributing for step by step process.