Git将开发分支与主版本合并为生产版本 [英] Git merging development branch with master for production versions

查看:293
本文介绍了Git将开发分支与主版本合并为生产版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Git进行代码版本控制.

I'm using Git for code versioning.

我有一个开发分支,在该分支上,我正在进行所有肮脏的开发.

I have a development branch on which i'm doing all the dirty development.

每次我向世界发布生产版本时,我都希望将其放在主分支下.

Every time I publish a production version to the world, I want to put it under my master branch.

问题在于,每当我合并开发人员和master时,master都会收到所有开发历史.

The problem is that whenever I merge development and master, master receive all development history.

我想保持一切清洁,以便分支看起来像这样:

I want to keep everything clean so the branches will look like this:

发展

初始化提交"

正在开发"

"1.0版"

错误修复"

错误修复"

"1.1版"

母版

"1.0版"

"1.1版"

有可能吗?如果可以,怎么办?

Is it possible? and if so, how ?

更新 我尝试使用Gauthier答案,但未如我所愿.

UPDATE I tried to use Gauthier answer but it doesn't worked as I wanted.

我采取的步骤如下: 1.在master中创建一个init commit 2.转投发展. 3.增加了对开发的承诺. 4.结帐大师 5. git merge开发--no-ff

The steps I took was as followed: 1. created an init commit in master 2. switched to development. 3. added few commits to development. 4. checkout master 5. git merge development --no-ff

合并成功,但是当我在存储库中进行高级别查找时,我看到在我的master分支中,我拥有开发分支的所有历史记录,而我只想拥有init ----- version 1.0.

The merge was successful but when i'm looking on high level at my repository, I see that in my master branch I have all the history of the development branch, while I wanted to have only init-----version 1.0.

这是外观的屏幕截图:

开发部门:

主分支:

推荐答案

您了解--no-ff吗?

您当前拥有:

o init commit
|
o developing
| 
o Version 1.0
|
o bug fixing
|
o bug fixing
|
o Version 1.1
|
o Version 1.0
|
o Version 1.1  - development - master

(时间在您的示例中下降,而不是git loggitk所做的事情)

(time going downwards as in your example, instead of what git log and gitk do)

我的猜测是您对master不满意,因为所有内容都直接到达同一级别.

My guess is that you are unhappy with master because everything gets directly there, at the same level.

如果您愿意:

o init commit
|\
| o developing
|/ 
o Merge branch 'development' - Version 1.0
|\
| o bug fixing
| |
| o bug fixing
|/
o Merge branch 'development' - Version 1.1 - development - master

然后,当您要释放development中的内容时,使用--no-ff合并到master,并标记:

then when you want to release what you have in development, merge to master with --no-ff, and tag:

$ git checkout master
$ git merge development --no-ff
$ git tag "v1.0"

请注意,您应该考虑在以您正在使用的功能命名的分支中工作,而不是在development中的所有工作.这将导致更好的合并消息,例如合并分支'killer_feature'".也许这就是您在development中所拥有的,在这种情况下,很抱歉.

Note that you should consider working in branches named after the feature you are working on, rather than everything in development. This would lead to better merge messages, such as "Merge branch 'killer_feature'". Maybe that's what you have in development already, in that case, sorry.

这篇关于Git将开发分支与主版本合并为生产版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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