樱桃采摘的替代品 [英] Alternatives to cherry-picking

查看:152
本文介绍了樱桃采摘的替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个主人和一个生产分支。主分支包含当前的开发,而生产分支包含正在服务器上运行的东西。有时会有一个重要的错误修正必须应用于两个分支。



目前我们只是在主分支上创建提交后才选择提交。但是,当我们合并分支时,这有时会产生合并冲突。 是否有其他选择?

解决方案

您可以创建一个新分支在 master 产品

的合并基础上,使用 bugfix -a >

  git checkout -b bugfix -a $(git merge-base master production)
pre>

在你的分支中应用你的bugfix

$ p $ >> / path / to / file echo'修正错误'
git add / path / to / file
git commit -m'重要错误修正'

然后,将这个新分支合并到master和production:

  git checkout master 
git merge bugfix -a
git checkout production
git merge bugfix -a

这样你就可以在晚些时候合并master和production,并且Git会很聪明地弄清楚哪些提交选择。



(单调 - 是的,它不是Git - 称这个工作为基础w daggy fixes


We have a master and a production branch. The master branch contains current developments while the production branch contains the stuff that is running on the server. From time to time, there is an important bugfix that has to be applied to both branches.

Currently we are just cherry-picking the commit after creating it on the master branch. But this sometimes creates merge conflicts when we are merging the branches. Are there alternatives?

解决方案

You can create a new branch (let's call it bugfix-a) at the merge base of master and production

git checkout -b bugfix-a $(git merge-base master production)

Apply your bugfix in that branch

>>/path/to/file echo 'this fixes the bug'
git add /path/to/file
git commit -m 'important bugfix'

Then, merge this new branch to both master and production:

git checkout master
git merge bugfix-a
git checkout production
git merge bugfix-a

That way you should be able to merge master and production at a later date and Git will be clever enough to figure out which commits to pick.

(Monotone – yes, it's not Git – calls this workflow daggy fixes)

这篇关于樱桃采摘的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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