我怎样才能轻松地在Git的几个发布分支上应用bug修复? [英] How can I easily apply a bugfix on several release branches in Git?

查看:167
本文介绍了我怎样才能轻松地在Git的几个发布分支上应用bug修复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用git来开发我的独角兽,但直到现在我还没有遇到任何棘手的分支问题,而且我似乎忘记了一些基本的东西,我在阅读后毫无疑问地知道使用Git Book的语用版本控制。



我通常会在我的网站上发布的内容之前发布几个版本,以便在发布错误报告时,只将它们应用到当前的主分支,而不是将它们修复到下一个发布的版本。当然,我想改变这种情况,以便更快地修复。



假设1.0刚刚发布,1.1即将发布,但我已经在1.3上工作了,例如

  1.0  - 发布
1.1 - 完成
1.2 - 完成
1.3 - 开发中

一个错误报告出现在..通常这会在1.3中修复,但是如何修复它而不是1.1?

据我所知,在svn和其他传统源代码控制系统中,我需要分支B.1.1和B.1.2并将更改应用到每个分支,然后从每个分支构建,最后将修复应用到主分支。



我似乎记得,但git巧妙地做了一些事情:I branch B .1.1,在那里进行更改,执行{something}和B.1.2,并使用修订自动更新主分支。这是可能的还是我想象的{something}?

解决方案

在这种情况下,正确的方法是:




  • 确保您创建了B1.1和B1.2(以在各自分支中隔离最终修复) >在master上应用你的补丁

  • cherry-pick提交给B1和B2



此主题中提到,这将: p>


确保主程序不会相对于较旧的分支进行倒退。 (不要使用merge,除非你想将所有的更改从一个分支合并到另一个分支,而不仅仅是你提到的单个提交
。)



I've been using git for a while for my one-man developments, but I haven't run into any tricky branching issues until now and I seem to have forgotten something fundamental that I no doubt "knew" just after reading the Pragmatic Version Control Using Git Book..

I'm often several releases ahead of what is actually published on my website, so that when a bug report comes in, I only apply them to the current master branch rather than fixing them in the next released version. Of course, I'd like to change that to get fixes out quicker.

Let's say 1.0 was just released, 1.1 is going to be released soon, but I'm already working on 1.3, e.g.

1.0 - released  
1.1 - finished  
1.2 - finished  
1.3 - in development  

A bug report comes in.. usually this would be fixed in 1.3, but how do I fix it in 1.1 instead?

As far as I am aware in svn and other "traditional" source control systems, I would need to branch B.1.1 and B.1.2 and apply the changes to each branch in turn, then build from each branch and finally apply the fix to the master branch.

I seem to remember that git, however, does something clever: I branch B.1.1, make the changes there, do {something} and B.1.2 and the master branches are automagically updated with the fix. Is this possible or did I imagine {something}?

解决方案

The right way in this case would be to:

  • make sure you have B1.1 and B1.2 created (to isolate final fixes in their respective branch)
  • apply your patch on master
  • cherry-pick that commit to B1 and B2

As mentionned in this thread, that would:

ensures master doesn't regress with respect to an older branch. (Do not use merge unless you want to merge all changes from one branch to another, rather than just the single commit you mention.)

这篇关于我怎样才能轻松地在Git的几个发布分支上应用bug修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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