简体   繁体   English

将修补程序分支合并到master而不是dev中

[英]Merging a hotfix branch into master but not dev

In my project, I have two main branches: master and dev . 在我的项目中,我有两个主要分支: masterdev I've been doing a lot of work on the dev branch as I finish up a new release. 当我完成一个新版本时,我在dev分支上做了很多工作。 I have identified an issue in my current master branch that needs to be fixed. 我在当前的master分支中发现了一个需要修复的问题。 The only issue is, in my dev branch, I have completely overhauled that same file. 唯一的问题是,在我的dev分支中,我已经彻底检查了该文件。 When I make a hotfix branch, I usually merge it back into both master and dev . 创建hotfix分支时,通常将其合并回masterdev But in a situation like this, I think I would get lots of merge conflicts. 但是在这种情况下,我认为我会遇到很多合并冲突。 Is it okay to simply merge this into master without merging it into dev ? 可以简单地将其合并到master而不将其合并到dev吗? Can I expect merge conflicts when I merge dev back into master ? dev合并回master时,可以期望合并冲突吗? Thanks! 谢谢!

It is fine not to merge it; 最好不合并它。 but, it is also possible to merge and to resolve all the conflicts in the favor of the dev branch. 但是,也有可能在dev分支的支持下合并并解决所有冲突。 By doing the merge, you maintain the similarity between the master and dev branches structure-wise. 通过进行合并,您可以在结构上维护masterdev分支之间的相似性。 The procedure is: 程序是:

$ git checkout dev
$ git merge hotfix
# conflicts arise, use `dev`
$ git checkout --ours -- <filename>  # --ours is the key.
$ git add <filename>
$ git commit ...

When you merge dev into master you might have conflicts but you will revolve them with --theirs (use the file from dev , not master ). 当您将dev合并到master您可能会遇到冲突,但是您将使用--theirs来解决--theirs (使用dev的文件,而不是master )。

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

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