git 什么是合并请求?

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

What is a merge request?

gitgit-merge

提问by sandalone

On services offering cloud Git repositories, I always find merge requests. What is its purpose? Who was supposed to create it?

在提供云 Git 存储库的服务上,我总能找到合并请求。它的目的是什么?谁应该创造它?

Also, what+s the lifecycle of a merge request? Someone creates it, and then - what cycles it should pass?

另外,合并请求的生命周期是什么?有人创造了它,然后 - 它应该通过什么周期?

回答by Rahul Mishra

Merge Request and Pull request basically refers to same thing. Tools such as GitHub and Bitbucket choose the name pull requestsince the first manual action would be to pull the feature branch. Tools such as GitLab and Gitorious choose the name merge requestsince that is the final action that is requested of the assignee.

合并请求和拉取请求基本上是指同一件事。GitHub 和 Bitbucket 等工具选择名称拉取请求,因为第一个手动操作是拉取功能分支。GitLab 和 Gitorious 等工具选择名称合并请求,因为这是请求受让人的最终操作。

Pull/Merge requests are created if you are working in a feature branch and wants to merge your change in main branch(eg. Master branch). The merge requests serves as a code review tool and if your code reveals shortcomings/issues anyone(usually other developers) can commit and push a fix.

如果您在功能分支中工作并希望在主分支(例如主分支)中合并您的更改,则会创建拉取/合并请求。合并请求用作代码工具,如果您的代码揭示了缺点/问题,任何人(通常是其他开发人员)都可以提交并推送修复。

Life cycle : You create a branch, fix some issue or add a feature, create a pull/merge request, then you assign it to someone, he/she will review your fix and can accept/reject the pull/merge request.

生命周期:您创建一个分支,修复一些问题或添加一个功能,创建一个拉取/合并请求,然后将其分配给某人,他/她将您的修复并可以接受/拒绝拉取/合并请求。

Please note that a merge/pull request should not be confused with the "git merge" or "git pull" command.

请注意,合并/拉取请求不应与“git merge”或“git pull”命令混淆。

回答by flungo

I believe you are referring to pull requests (PR) which you merge into your master branch. Pull requests are the standard way of people who have branched off (forked) your code to then commit back to the master branch. Generally one PR should solve one bug or add one feature. This is usually achieved using feature branches on the forked code and then creating a pull request on that branch when the feature is completed. This makes merging much easier and means that if you work on multiple features and one is rejected but the other is accepted, their branches do not collide.

我相信您指的是合并到主分支中的拉取请求 (PR)。拉取请求是分支(分叉)您的代码然后提交回主分支的人的标准方式。通常,一个 PR 应该解决一个错误或添加一个功能。这通常是通过在分叉代码上使用功能分支来实现的,然后在功能完成时在该分支上创建拉取请求。这使得合并更容易,并且意味着如果您处理多个功能并且一个被拒绝但另一个被接受,它们的分支不会发生冲突。

So to answer your question of who is supposed to create them, it is usually people who have forked your code. This may even be people on your development team if that's how you choose to work. The main area where this works is with public open source projects. For example, openssl has a public github that anyone can fork, and then if someone wanted to add a feature or fix a bug they would: fork, branch, commit, push and submit a PR.

因此,要回答谁应该创建它们的问题,通常是人们分叉了您的代码。如果这是您选择的工作方式,这甚至可能是您的开发团队中的人。它的主要工作领域是公共开源项目。例如,openssl 有一个任何人都可以 fork 的公共 github,然后如果有人想添加功能或修复错误,他们会:fork、分支、提交、推送和提交 PR。

Once a PR is created, the lifecycle it takes is down to you. It is not predefined. In general the least you must do is: decide if the bug or feature is worthwhile, check over the code to ensure it does what it says and is well written and meets any coding standard set out for your project and then if it good, accept it and merge it.

创建 PR 后,其生命周期取决于您。它不是预定义的。一般来说,您至少必须做的是:确定错误或功能是否值得,检查代码以确保它按照规定执行并且编写得很好并且符合为您的项目设定的任何编码标准,然后如果它很好,接受它并合并它。

You can make the lifecycle more complicated by having it go to a development branch to be tested by testers with other development features before being merged into the master but really it is down to you to find a workflow that works for your project.

在合并到主分支之前,您可以将它转到开发分支,由测试人员使用其他开发功能进行测试,从而使生命周期变得更加复杂,但实际上,找到适合您项目的工作流程取决于您。