gitlab 请求将分支 A 合并到开发中(后面有 3 个提交)我应该担心吗? [英] gitlab Request to merge branch-A into develop (3 commits behind) should I worry?

查看:26
本文介绍了gitlab 请求将分支 A 合并到开发中(后面有 3 个提交)我应该担心吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 gitlab 中创建合并请求时,我经常收到一条消息:请求将分支 A 合并到开发中([x] 提交后)gitlab 想告诉我什么?我应该担心还是需要解决一些问题(什么)?

When creating a merge request in gitlab I often get a message: Request to merge branch-A into develop ([x] commits behind) what does gitlab want to tell me? should I worry or do I need to fix something (what)?

推荐答案

一段时间后,合并请求在项目中打开,您尝试合并到的分支版本是正常的由于其他人将自己的更改合并到它而变得过时.

After some time a merge request is open in a project it is normal that the version of the branch you are trying to merge into becomes outdated due to other people merging their own changes to it.

Gitlab 通过显示您更新的分支版本落后于远程分支的程度来帮助您.

Gitlab helps you by showing how much the version of the branch you updated is behind the remote branch.

落后不会对合并的行为造成任何阻碍,但是将提交 rebase 放在合并到的分支之上是一种常见的做法.这将通过将您的提交按时间顺序放在该分支中已经存在的提交之后来更新您的合并请求.这种方法使负责合并的人的工作更容易,因为提交者自己已经解决了可能发生的任何冲突.

Being behind will not set any hindrance to the act of merging, but it is a common practice to rebase your commits on top of the branch your merging into. This will make your merge request updated by putting your commits chronologically after the ones that already are in that branch. That approach makes the work of the person responsible for the merge easier because the commiter himself has already resolved any conflicts that would have happened.

要按照您建议的方案执行 rebase,如下所示:

To do a rebase following the scenario you proposed would be like this:

# Add a remote named `upstream` pointing to the original repository
git remote add upstream https://gitlab.example.com/example/your_project.git

# Fetch the latest commmits from `upstream`
git fetch upstream

# Checkout our branch-A
git checkout branch-A

# Rebase our branch on top of the `upstream/develop` branch
git rebase upstream/develop

# If needed fix any conflicts that may have appeared and then `git rebase --continue`  

# Push the changes to the branch of your merge request
git push --force origin branch-A

注意: --force 标志在你推送时是必需的,因为你正在重写 origin/branch-A 的提交历史.来自 git 的文档:

Note: The --force flag is necessary when you push because you are rewriting the commit history of origin/branch-A. From git's doc:

[--force] 会导致远程仓库丢失提交;小心使用.

[--force] can cause the remote repository to lose commits; use it with care.

这篇关于gitlab 请求将分支 A 合并到开发中(后面有 3 个提交)我应该担心吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆