[英]git - Merging a hotfix into dev and master causes divergence
我正在追随成功的Git分支模型 (又名git-flow)。
我按照完成修补程序分支一节中的指导做了一个修补程序 。
我在master下创建了一个修补程序分支:
> git checkout -b hotfix upstream/master
有些工作并手动将其合并为master :
> git checkout master
> git merge --no-ff hotfix
然后手动将其合并回dev :
> git checkout dev
> git merge --no-ff hotfix
我做了一些工作 - 对dev的提交。 一切似乎都很好。 但是当我把dev合并成master时 ,它却无法实现。
> git checkout master
> git merge --ff-only dev
fatal: Not possible to fast-forward, aborting.
看起来修复程序的合并提交是不同的。
我假设遵循这个过程将保持共同的历史。 我做错了什么?
您没有提供有关历史记录拓扑的详细信息,因此从一般情况开始并创建hotfix
$ git checkout -b hotfix upstream/master $ git lola * 81a514a (dev) Stupendous feature * cb4d5e6 Great feature * d4a7906 Cool feature | * 39e449a (HEAD, upstream/master, hotfix) v0.2 |/ * 264ddbc (master) v0.1
注意: git lola
是一个非标准但非常有用的别名。
将hotfix
合并到master
* 567f066 (HEAD, master) Merge branch 'hotfix' |\ | * 1b1b6e3 (hotfix) Fix nasty bug | * 39e449a (upstream/master) v0.2 |/ | * 81a514a (dev) Stupendous feature | * cb4d5e6 Great feature | * d4a7906 Cool feature |/ * 264ddbc v0.1
将hotfix
单独合并到dev
是事情偏离轨道的地方。
* 36aa1c8 (HEAD, dev) Merge branch 'hotfix' into dev |\ * | 81a514a Stupendous feature * | cb4d5e6 Great feature * | d4a7906 Cool feature | | * 567f066 (master) Merge branch 'hotfix' | | |\ | |/ / |/| / | |/ | * 1b1b6e3 (hotfix) Fix nasty bug | * 39e449a (upstream/master) v0.2 |/ * 264ddbc v0.1
在这一点上, master
是不是直系祖先dev
,但其兄弟。
添加更多提交到dev
让master
成为伟大的叔叔。
* d89aa74 (HEAD, dev) Jason does it again * a4dd5bf Jason saves the day * 36aa1c8 Merge branch 'hotfix' into dev |\ * | 81a514a Stupendous feature * | cb4d5e6 Great feature * | d4a7906 Cool feature | | * 567f066 (master) Merge branch 'hotfix' | | |\ | |/ / |/| / | |/ | * 1b1b6e3 (hotfix) Fix nasty bug | * 39e449a (upstream/master) v0.2 |/ * 264ddbc v0.1
回想一下, dev
通过一个功能分支进入master
,并通过--no-ff
合并。 也许release-1.0
从您的修补程序开始,并获得另一个错误修复。
* f0398ba (HEAD, release-1.0) Bugfix for v1.0 * d89aa74 (dev) Jason does it again * a4dd5bf Jason saves the day * 36aa1c8 Merge branch 'hotfix' into dev |\ * | 81a514a Stupendous feature * | cb4d5e6 Great feature * | d4a7906 Cool feature | | * 567f066 (master) Merge branch 'hotfix' | | |\ | |/ / |/| / | |/ | * 1b1b6e3 (hotfix) Fix nasty bug | * 39e449a (upstream/master) v0.2 |/ * 264ddbc v0.1
假设按钮向上释放,这可以追溯到master
$ git merge --no-ff -m "v1.0" release-1.0 $ git lola * 5a384c8 (HEAD, master) v1.0 |\ | * f0398ba (release-1.0) Bugfix for v1.0 | * d89aa74 (dev) Jason does it again | * a4dd5bf Jason saves the day | * 36aa1c8 Merge branch 'hotfix' into dev | |\ | * | 81a514a Stupendous feature | * | cb4d5e6 Great feature | * | d4a7906 Cool feature * | | 567f066 Merge branch 'hotfix' |\ \ \ | |/ / |/| / | |/ | * 1b1b6e3 (hotfix) Fix nasty bug | * 39e449a (upstream/master) v0.2 |/ * 264ddbc v0.1
当然,对您的确切修复取决于您的历史记录的具体情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.