What's the difference between a Pull Request and a branch?

SkyWalker picture SkyWalker · Sep 27, 2013 · Viewed 15.1k times · Source

In the context of GitHub and Atlassian Stash, there is a common feature to do a Pull Request. What's the difference between a Pull Request and a branch? a Pull Request looks like a different way to call a branch or?

Answer

Rog picture Rog · Sep 28, 2013

A pull request signals that you want some changes in your branch merged to a target branch.

One example might be that you make a new branch "my-feature" based on the current development branch (say, "master"). When you are done, you can push your branch to the remote repo and create a pull request from "my-feature" to "master". The pull request gives people an opportunity to review the change and comment, and you may push additional changes on the same branch in response to feedback which will be updated in the pull request. When the code is good to merge, someone can then apply the merge to master and the pull request is closed.

You can of course merge branches without first creating a pull request, but the benefit of pull requests comes for collaboration. In Stash, you can configure who can merge to which branches, and require a certain number of passing builds or approvals before the merge can be done. In a team environment such a workflow helps improve code quality and developer speed.