问题
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?
回答1:
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.)
回答2:
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(-)
回答3:
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.
来源:https://stackoverflow.com/questions/22585407/git-pull-vs-pull-request