简体   繁体   English

我们可以在 Gitlab 中创建具有相同功能分支的不同合并请求吗?

[英]Can we create different Merge requests with same feature branch in Gitlab?

How can we create different Merge requests with same branch?我们如何使用相同的分支创建不同的合并请求? I'm working as example with the branch feature/task1 .我以分支feature/task1为例。 I commited those changes and created one Merge Request.我提交了这些更改并创建了一个合并请求。 Now I want to use the same feature branch but I want to create a new Merge Request.现在我想使用相同的功能分支,但我想创建一个的合并请求。 How can I achieve this?我怎样才能做到这一点?

If what you mean to do is split work on a feature in multiple partial PRs, sure there is no problem.如果您的意思是在多个部分 PR 中拆分一个功能的工作,那么肯定没有问题。 However, you need to be careful with a number of scenarios:但是,您需要小心一些场景:

push second part of the feature推送功能的第二部分

Need to be careful not to push into the same remote branch as the first part if it hasn't been merged yet.如果尚未合并,则需要注意不要将其推送到与第一部分相同的远程分支 If you did that, the first PR would be updated to include the changes that you mean to include in the 2nd PR.如果您这样做了,第一个PR 将被更新以包含您打算包含在第二个 PR 中的更改。

Another problem is how you want people to see your changes in the PR.另一个问题是您希望人们如何看到您在 PR 中的更改。 If you provide main (for example) as the target branch, then the PR will show all changes, including the ones of the first PR.如果您提供main (例如)作为目标分支,则 PR 将显示所有更改,包括第一个 PR 的更改。 In cases like this I set the target branch to be the first PR branch so that only the changes of the second PR are visible.在这种情况下,我将目标分支设置为第一个PR 分支,以便只有第二个 PR 的更改可见。 When the first PR is merged, then I change the target branch to be the real target branch.合并第一个 PR 后,我将目标分支更改为真正的目标分支。

Careful if you decide to rebase如果您决定变基,请小心

If you develop the second part of the feature and you decide to rebase, you need to make sure to also rebase the changes of the first PR.如果您开发了该功能的第二部分并决定变基,则需要确保变基第一个 PR 的更改。

So, if could be done like this (after fetching, if working with a remote)所以,如果可以这样做(在获取之后,如果使用遥控器)

git checkout first-part-of-feature
git branch temp # leave a temp branch over here, we will need it later
git rebase upstream/main # or whatever branch
git push # push into the remote branch
# now let's rebase the second part of the feature branch
git rebase --onto first-part-of-pr temp second-part-of-pr
# and now you got the second part on top of the first part
# and now you can push

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Gitlab 中更改多个合并请求的目标分支 - How can change the target branch for multiple Merge requests in Gitlab 我可以在合并后对同一功能分支进行另一次合并吗? - Can I do another merge of the same feature branch after a merge? 我们可以从发布分支创建功能分支吗 - Can we create feature branch from release branch feature 分支在 master 后面,feature 和 master 在同一个文件上不会改变,在合并 PR 之前是否必须将 master 合并到 feature 中? - feature branch is behind master, feature and master do not change on same files, is it a must to merge master into feature before we merge the PR? 如果目标分支后面有一些提交,我们如何限制git不允许功能分支合并 - How can we restrict git to not allow merge from the feature branch if it is some commits behind the destination branch 在gitflow中,如果我们有一个发布分支开放了一个星期,我们仍然可以将功能分支合并到开发中吗 - In gitflow if we have a release branch open for one week can we still merge feature branches into develop 无法创建提取请求以将功能分支合并到新创建的存储库中的master分支中 - Can't create a pull request to merge a feature branch into a master branch in a newly created repository Git在压缩和合并之前创建功能分支 - Git create feature branch before squash and merge GIT merge develop into feature branch -- 同一个分支被合并和恢复后 - GIT merge develop into feature branch -- after the same branch was merged and reverted 合并分支与标签 - Gitlab - Merge a branch with tag - Gitlab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM