当开发分支与主控非常不同时管理修补程序? [英] Managing hotfixes when develop branch is very different from master?

查看:112
本文介绍了当开发分支与主控非常不同时管理修补程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Git Flow分支模型,包含主分支和开发分支。我正在开发一个重要的新版本,所以我的开发分支与我的主分支大不相同。这在任何时候需要在master分支上制作热补丁并将其重新合并为开发时都会产生问题。几乎总是存在冲突,并且正在变成真正的痛苦。

管理这个最好的方法是什么?对我来说,手动开发小​​修补程序更改会更容易,然后在准备就绪时将所有内容合并到主服务器中,而无需将主机合并到开发中。这可能吗?

解决方案 从一个分支到另一个分支提交的最简单方法是<摘樱桃。假设您在 master 中的修复包含提交哈希 HASH ,并且你想把这个修补程序放到你的 devel 分支中,做一个 git checkout devel ,后面跟一个 git cherry-pick HASH 。就是这样。



如果您想将 master 中的所有更改转换为 devel ,你可以通过

  git checkout devel 
git rebase master






如果您有相反的情况在开发过程中在 devel 分支中创建一个修补程序,并希望在之前将该修补程序修改为 master devel 完全合并到 master ),工作流非常相似。假设修补程序有散列 HOTFIX_HASH ,请执行以下操作:

  git checkout master 
git cherry-pick HOTFIX_HASH

现在,提交出现在 master devel 。要解决这个问题,请输入

  git checkout devel 
git rebase master

并且提交将从 devel 中消失,因为它已经存在于主人


I'm using the "Git Flow" branching model, with a master branch and a develop branch. I'm working on a major new release, so my develop branch is wildly different from my master branch. This creates a problem anytime I need to make a hotfix on the master branch and merge it back into develop. There are almost always conflicts, and it's becoming a real pain.

What is the best way to manage this? It would be easier for me to make the small hotfix changes on develop manually and then merge everything into master when I'm ready without merging master back into develop. Is this possible?

解决方案

The simplest way to get some commits from one branch to another is cherry-picking.

Assuming that your fix in master has the commit hash HASH and you want to take that hotfix into your devel branch, do a git checkout devel followed by a git cherry-pick HASH. That's it.

If you want to take all changes from master into devel, you can achieve that with

git checkout devel
git rebase master


If you have the opposite scenario (you make a hotfix during development in a devel branch and want to take that fix into master before devel gets fully merged into master), the workflow is quite similar. Assuming that the hotfix has the hash HOTFIX_HASH, do this:

git checkout master
git cherry-pick HOTFIX_HASH

Now, the commit is present in master and devel. To get around this, type

git checkout devel
git rebase master

and the commit will disappear from devel since it's already present in master.

这篇关于当开发分支与主控非常不同时管理修补程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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