69

I'm new to using Git, so I apologize if this is trivial. I have a private repository set up using Github and EGit.

To update and merge my local repository branch with the remote version (essentially a git pull), I use Team > Pull in Eclipse.

To merge a branch into the master branch, I have to request and subsequently approve a Pull Request on Github.

What is the difference between calling git pull and sending a pull request?

I've seen that this is related to a Fork and Pull collaborative development model and is used for code reviews. I think I understand the motivation and usefulness of a pull request, but what exactly is it?

Jonn
  • 1,594
  • 1
  • 14
  • 25
  • 1
    Seriously they have created all ultra-confusing terminologies: 1. Clone Vs Pull request Vs Branch Vs Git pull Vs Fetch 2. Push Vs Commit Vs Check-in Vs Git add 3. Now what is merge ? – Atul Oct 20 '19 at 11:16

3 Answers3

94

If you use git pull, you pull the changes from the remote repository into yours.

If you send a pull request to another repository, you ask their maintainers to pull your changes into theirs (you more or less ask them to use a git pull from your repository).

If you are the maintainer of that repository, it seems you're making it a bit more difficult by pretending you're playing two roles in that workflow. You might as well merge locally your development branch into your master branch and push that master branch into your GitHub repository directly.

(As a side note, if you're new to Git, I'd suggest using git fetch and then git merge instead of git pull. git pull is effectively git fetch followed by git merge, but doing them separately gives you better control over potential conflicts.)

Bruno
  • 119,590
  • 31
  • 270
  • 376
  • Thanks for the response. So are separate branches effectively distinct repositories? The maintainer of the master repository receives your branch with an option to merge those changes into the master branch? – Jonn Mar 23 '14 at 00:25
  • 5
    Not really, you can have multiple branches in a repository. There isn't really a notion of "master" repository, rather that of the maintainer/official repository (it's more an administrative concept). "Forking" on GitHub clones the repository into your account, so you have a separate repository to publish your changes and invite the main repository's maintainer to pull your changes (by the means of pull requests). Pull requests are mainly a GitHub (or Gitlab/Gitorious) concept for managing the collaboration, it's not quite directly related to Git itself. – Bruno Mar 23 '14 at 00:33
  • 2
    That makes sense. So it seems mostly applicable to a decentralized open source project. In another answer @TimWolla mentioned the `git request-pull` command. Is this not a standard Git feature? – Jonn Mar 23 '14 at 00:40
  • 5
    `git request-pull` seems more of a "convenience" command, to present the message you'd send to the maintainers, so that they'll know what to pull (e.g. ready to be e-mailed). It's documented [here](http://git-scm.com/book/ch5-2.html): "*When your work has been pushed up to your fork, you need to notify the maintainer. This is often called a pull request, and you can either generate it via the website — GitHub has a "pull request" button that automatically messages the maintainer — or run the git request-pull command and e-mail the output to the project maintainer manually.*" – Bruno Mar 23 '14 at 00:49
11

A pull request is requesting the maintainer of a repository to git pull in some changes (as the name already suggests). GitHub provides an additional easy to use interface that simplifies review of such a request.
You don't need to use it to merge in some branch. But you can use it and it may be helpful to recheck whether all changes are ready to be merged. If you don't want or need that additional safety you can simply git merge the branch.


git itself also has a command that creates a pull request, designed for the use in mailing lists. You can request the generation with the git request-pull command. In fact it is required to hand in a pull request for some projects using this command! The output of the command looks similar to this (taken from the official git homepage):

$ git request-pull origin/master myfork
The following changes since commit 1edee6b1d61823a2de3b09c160d7080b8d1b3a40:
  John Smith (1):
        added a new function

are available in the git repository at:

  git://githost/simplegit.git featureA

Jessica Smith (2):
      add limit to log function
      change log output to 30 from 25

 lib/simplegit.rb |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
TimWolla
  • 31,849
  • 8
  • 63
  • 96
4

Git Pull

Remote Repo======>local repo

git pull=Git Fetch + Git Merge

Pull Request

It's a Github thing.

Remote Github Repo<========Pull Request from=====Your Github Repo

Whether the maintainer of the remote github repo will accept your pull request or not, is on her.

Asif
  • 664
  • 1
  • 7
  • 14