git 拉取请求与合并请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22199432/
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:50:45  来源:igfitidea点击:

Pull request vs Merge request

gitgithubgitlab

提问by Pacane

What is the difference between a Pull request and a Merge request.

拉取请求和合并请求有什么区别。

In Github it's a Pull Request and in GitLab for example, it's a Merge Request... Is there a difference between both of these?

在 Github 中它是一个拉取请求,例如在 GitLab 中,它是一个合并请求......这两者之间有区别吗?

回答by gilly3

GitLab's "merge request"feature is equivalent to GitHub's "pull request"feature. Both are means of pulling changes from another branch or fork into your branch and merging the changes with your existing code. They are useful tools for code review and change management.

GitLab 的“合并请求”功能相当于 GitHub 的“拉取请求”功能。两者都是将更改从另一个分支或分支拉入您的分支并将更改与现有代码合并的方法。它们是用于代码和变更管理的有用工具。

An article from GitLabdiscusses the differences in naming the feature:

GitLab一篇文章讨论了命名功能的差异:

Merge or pull requests are created in a git management application and ask an assigned person to merge two branches. Tools such as GitHub and Bitbucket choose the name pull request since the first manual action would be to pull the feature branch. Tools such as GitLab and Gitorious choose the name merge request since that is the final action that is requested of the assignee. In this article we'll refer to them as merge requests.

合并或拉取请求是在 git 管理应用程序中创建的,并要求指定的人合并两个分支。GitHub 和 Bitbucket 等工具选择名称拉取请求,因为第一个手动操作是拉取功能分支。GitLab 和 Gitorious 等工具选择名称合并请求,因为这是请求受让人的最终操作。在本文中,我们将它们称为合并请求。

A "merge request" should not be confused with the git mergecommand. Neither should a "pull request" be confused with the git pullcommand. Both gitcommands are used behind the scenes in both pull requests and merge requests, but a merge/pull request refers to a much broader topic than just these two commands.

“合并请求”不应与git merge命令混淆。“拉取请求”也不应该与git pull命令混淆。这两个git命令都在拉取请求和合并请求的幕后使用,但合并/拉取请求所指的主题比这两个命令要广泛得多。

回答by rneves

They are the same feature

它们是相同的功能

Merge or pull requests are created in a git management application and ask an assigned person to merge two branches. Tools such as GitHub and Bitbucket choose the name pull request since the first manual action would be to pull the feature branch. Tools such as GitLab and Gitorious choose the name merge request since that is the final action that is requested of the assignee. In this article we'll refer to them as merge requests.

-- https://about.gitlab.com/2014/09/29/gitlab-flow/

合并或拉取请求是在 git 管理应用程序中创建的,并要求指定的人合并两个分支。GitHub 和 Bitbucket 等工具选择名称拉取请求,因为第一个手动操作是拉取功能分支。GitLab 和 Gitorious 等工具选择名称合并请求,因为这是请求受让人的最终操作。在本文中,我们将它们称为合并请求。

-- https://about.gitlab.com/2014/09/29/gitlab-flow/

回答by K. Symbol

In my point of view, they mean the same activity but from different perspectives:

在我看来,它们意味着相同的活动,但从不同的角度来看:

Think about that, Alice makes some commits on repository A, which was forked from Bob's repository B.

想想看,Alice 在存储库 A 上进行了一些提交,该存储库是从 Bob 的存储库 B 分叉出来的。

When Alice wants to "merge" her changes into B, she actually wants Bob to "pull" these changes from A.

当 Alice 想要将她的更改“合并”到 B 中时,她实际上希望 Bob 从 A 中“拉出”这些更改。

Therefore, from Alice's point of view, it is a "merge request", while Bob views it as a "pull request".

因此,从 Alice 的角度来看,它是一个“合并请求”,而 Bob 将其视为一个“拉取请求”。

回答by iclman

There is a subtle difference in terms of conflict management. In case of conflicts, a pull request in Github will result in a merge commit on the destinationbranch. In Gitlab, when a conflict is found, the modifications made will be on a merge commit on the sourcebranch.

在冲突管理方面存在细微差别。如果发生冲突,Github 中的拉取请求将导致目标分支上的合并提交。在 Gitlab 中,当发现冲突时,所做的修改将在分支上进行合并提交。

See https://docs.gitlab.com/ee/user/project/merge_requests/resolve_conflicts.html

https://docs.gitlab.com/ee/user/project/merge_requests/resolve_conflicts.html

"GitLab resolves conflicts by creating a merge commit in the source branch that is not automatically merged into the target branch. This allows the merge commit to be reviewed and tested before the changes are merged, preventing unintended changes entering the target branch without review or breaking the build."

“GitLab 通过在源分支中创建一个不会自动合并到目标分支的合并提交来解决冲突。这允许在合并更改之前和测试合并提交,防止意外的更改进入目标分支而无需或破坏建造。”

回答by VonC

GitLab 12.1 (July 2019) introduces a difference:

GitLab 12.1(2019 年 7 月)引入了一个不同之处:

"Merge Requests for Confidential Issues"

合并机密问题的请求

When discussing, planning and resolving confidential issues, such as security vulnerabilities, it can be particularly challenging for open source projects to remain efficient since the Git repository is public.

在讨论、规划和解决机密问题(例如安全漏洞)时,由于 Git 存储库是公开的,因此开源项目要保持高效尤其具有挑战性。

https://about.gitlab.com/images/12_1/mr-confidential.png

https://about.gitlab.com/images/12_1/mr-confidential.png

As of 12.1, it is now possible for confidential issues in a public project to be resolved within a streamlined workflow using the Create confidential merge request button, which helps you create a merge request in a private fork of the project.

从 12.1 开始,现在可以使用创建机密合并请求按钮在简化的工作流程中解决公共项目中的机密问题,这有助于您在项目的私有分支中创建合并请求。

See "Confidential issues" from issue 58583.

请参阅问题 58583 中的机密问题” 。

A similar feature exists in GitHub, but involves the creation of a special private fork, called "maintainer security advisory".

GitHub 中存在类似的功能,但涉及创建一个特殊的私有分支,称为“维护者安全建议”。

回答by Muhammad Shahbaz

As mentioned in previous answers, both serve almost same purpose. Personally I like git rebase and merge request (as in gitlab). It takes burden off of the reviewer/maintainer, making sure that while adding merge request, the feature branch includes all of the latest commits done on main branch after feature branch is created. Here is a very useful article explaining rebase in detail: https://git-scm.com/book/en/v2/Git-Branching-Rebasing

正如前面的答案中提到的,两者的用途几乎相同。我个人喜欢 git rebase 和合并请求(如在 gitlab 中)。它减轻了者/维护者的负担,确保在添加合并请求时,功能分支包含在创建功能分支后在主分支上完成的所有最新提交。这是一篇非常有用的文章,详细解释了 rebase:https: //git-scm.com/book/en/v2/Git-Branching-Rebasing