简体   繁体   English

Gitlab合并两个分支

[英]Gitlab merge two branches

We have created 'dev' branch from the 'master' and have been working on the 'dev' branch. 我们已经从“ master”创建了“ dev”分支,并一直在开发“ dev”分支。 We have not merged the 'dev' to 'master' yet. 我们还没有将'dev'合并到'master'。 Also at the same time we have created 'preprod' branch from the 'master' and working on the 'preprod' branch changes. 同样,我们同时从“ master”创建了“ preprod”分支,并致力于“ preprod”分支的更改。 We have not merged the 'preprod' to 'master' yet. 我们尚未将'preprod'合并为'master'。

Now what we are trying to achieve is to merge the 'preprod' changes alone to 'dev'. 现在,我们试图实现的是将“ preprod”更改单独合并为“ dev”。 I tried this by creating a merge request through Gitlab and approved it. 我尝试通过Gitlab创建合并请求并批准了该请求。 What I found is the changes in the 'dev' code was also moved to 'preprod' and vice versa. 我发现,“ dev”代码中的更改也移至“ preprod”,反之亦然。 I do not want the 'dev' changes to be moved to the 'preprod' by any chance. 我不希望将“ dev”更改转移到“ preprod”。 How can i accomplish this ? 我怎样才能做到这一点?

If you got changes on both, it is likely that your merge request told gitlab to merge the two branches into each other, which is sometimes desirable. 如果您在两者上都进行了更改,则合并请求可能会告诉gitlab将两个分支相互合并,这有时是理想的。 Depending on your development process, you may find it easier to use git itself (or a gui for it, for example git extensions or sourcetree) to do your merges. 根据您的开发过程,您可能会发现使用git本身(或gui的git扩展或sourcetree)进行合并会更容易。 GUI versions do a good job of visually showing your branches and past merges, which makes it a lot easier to figure out which commands to run. GUI版本在可视化显示分支和过去的合并方面做得很好,这使找出要运行的命令变得容易得多。

From the command line, after you revert to a commit before the gitlab merge, check out the dev branch and merge preprod into it: 从命令行,在gitlab合并之前恢复到提交之后,签出dev分支并将preprod合并到其中:

git checkout dev
git merge preprod

The preprod changes will be made on dev but not vice versa (don't forget to push dev). preprod更改将在dev上进行,反之亦然(不要忘记推动dev)。 The git merge command's effect is to merge changes from the named branch in the command (preprod) INTO the CURRENT branch (in this case dev, but you can verify the current branch running "git branch" or "git status"). git merge命令的作用是将命令(preprod)中命名分支的更改合并到CURRENT分支(在本例中为dev,但是您可以验证当前分支运行“ git branch”或“ git status”)。

Links to the git tools I mentioned: git extensions: https://sourceforge.net/projects/gitextensions/ SourceTree: https://www.sourcetreeapp.com/ 我提到的git工具的链接:git扩展: https: //sourceforge.net/projects/gitextensions/ SourceTree: https ://www.sourcetreeapp.com/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM