樱桃采摘的替代品

ibl*_*lue 8 git

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

目前,我们只是在主分支上创建它之后挑选提交.但是,当我们合并分支时,这有时会产生合并冲突.还有替代品吗?

kni*_*ttl 10

您可以创建一个新的分支(我们称之为bugfix-a在合并基础)masterproduction

git checkout -b bugfix-a $(git merge-base master production)
Run Code Online (Sandbox Code Playgroud)

在该分支中应用您的错误修复程序

>>/path/to/file echo 'this fixes the bug'
git add /path/to/file
git commit -m 'important bugfix'
Run Code Online (Sandbox Code Playgroud)

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

git checkout master
git merge bugfix-a
git checkout production
git merge bugfix-a
Run Code Online (Sandbox Code Playgroud)

这样你就可以在以后合并master和production,Git会聪明地知道要选择哪些提交.

(Monotone - 是的,它不是Git - 称这个工作流程为daggy修复)