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

19,327

Solution 1

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.

A separate version of the code is BRANCH

Solution 2

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.

Solution 3

A branch is just a separate version of the code.

A pull request is when someone take the repo, makes their own branch, does some changes, then tries to merge that branch in (put their changes in the other person's code repository). (In the most general of terms.)

Solution 4

There are a few workflows, that describe process how developers using git. One of them is Feature Branch Workflow

The core idea behind the Feature Branch Workflow is that all feature development should take place in a dedicated branch instead of the master branch.

Encapsulating feature development also makes it possible to leverage pull requests. Detailed example can be found at Feature Branches and Pull Requests : Walkthrough

There is a similar GitHub Standard Fork & Pull Request Workflow( or just Pull request workflow), where instead of creating a branch inside your own repository you create a fork from someone else repository.

Some people do not distinguish these concepts and use terms “feature branch workflow” and “pull request workflow” interchangeably. It can be confusing for others.

Share:
19,327

Related videos on Youtube

SkyWalker
Author by

SkyWalker

How would you be rated on a technical skill that you haven't used yet e.g. tableau? Check out my Stack Overflow skill recommender system: https://github.com/bravegag/HarvardX-Skillability

Updated on June 03, 2022

Comments

  • SkyWalker
    SkyWalker almost 2 years

    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?

  • eliu
    eliu over 4 years
    Why isn't pull reques feature named push request. Clearly the intention is to push your feature to the original master.
  • Rog
    Rog over 4 years
    @eliu the name comes from how changes were historically submitted. The submitter was usually requesting that a maintainer pull their changes in from some other location. While that's not always the case these days, the name largely stuck.
  • Rog
    Rog over 4 years
    ... see also the git command that facilitates this when pull requests traditionally happen via mailing lists instead of by way of an application that provides a pull request experience... git-scm.com/docs/git-request-pull