Git 拉取与拉取请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22585407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:54:17  来源:igfitidea点击:

Git Pull vs. Pull Request

gitgithubgit-pull

提问by Jonn

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

我是使用 Git 的新手,所以如果这是微不足道的,我深表歉意。我有一个使用 Github 和EGit设置的私有存储库。

To update and mergemy local repository branch with the remote version (essentially a git pull), I use Team > Pullin Eclipse.

为了更新和合并我的本地存储库分支与远程版本(本质上是 a git pull),我Team > Pull在 Eclipse 中使用。

To mergea branch intothe master branch, I have to request and subsequently approve a Pull Requeston Github.

要将分支合并主分支中,我必须在 Github 上请求并随后批准拉取请求

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

调用git pull和发送拉取请求有什么区别?

I've seen that this is related to a Fork and Pullcollaborative 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?

我已经看到这与Fork and Pull协作开发模型有关,用于代码。我想我理解拉取请求的动机和用处,但它到底是什么?

回答by Bruno

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

如果使用git pull,则将远程存储库中的更改拉入您的存储库中。

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

如果您向另一个存储库发送拉取请求,您要求他们的维护者将您的更改拉入他们的(您或多或少要求他们使用git pull您存储库中的一个)。

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.

如果您是该存储库的维护者,那么通过假装您在该工作流程中扮演两个角色,似乎会让它变得更加困难。您也可以在本地将您的开发分支合并到您的 master 分支,然后将该 master 分支直接推送到您的 GitHub 存储库中。

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

(附带说明,如果您是 Git 新手,我建议您使用git fetchand thengit merge而不是git pull.git pull有效地git fetch跟在.之后git merge,但单独使用它们可以让您更好地控制潜在的冲突。)

回答by TimWolla

A pull requestis requesting the maintainer of a repository to git pullin 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 needto use it to merge in some branch. But you canuse 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 mergethe branch.

一个拉请求请求存储库的维护者git pull在某些变化(如名字已经暗示)。GitHub 提供了一个额外的易于使用的界面,可简化对此类请求的。
不需要使用它来合并某个分支。但是您可以使用它,重新检查所有更改是否已准备好合并可能会有所帮助。如果您不想要或不需要额外的安全性,您可以简单地git merge使用分支。



gititself 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-pullcommand. 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它本身也有一个创建拉取请求的命令,专为在邮件列表中使用而设计。您可以使用git request-pull命令请求生成。事实上,使用此命令需要提交一些项目的拉取请求!命令的输出看起来与此类似(取自官方 git 主页):

$ 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(-)

回答by Asif

Git Pull

Git 拉取

Remote Repo======>local repo

远程仓库======>本地仓库

git pull=Git Fetch + Git Merge

git pull=Git 获取 + Git 合并

Pull Request

拉取请求

It's a Github thing.

这是一个 Github 的东西。

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

远程 Github 存储库<========从 ======您的 Github 存储库拉取请求

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

远程 github 存储库的维护者是否会接受您的拉取请求,取决于她。