[英]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:但是,您需要小心一些场景:
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 后,我将目标分支更改为真正的目标分支。
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.