Gitflow:我应该从发行版分支合并到主机时压缩提交吗? [英] Gitflow: Should I squash commits when merging from a release branch into master?

查看:156
本文介绍了Gitflow:我应该从发行版分支合并到主机时压缩提交吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将发布分支合并到master,我想知道是否应该将合并中的提交压缩为合并提交。关于git流程的一般文件包含这样一个来自Atlassian页面的数据:



在这些数字中,只有单个提交出现在master上,而不是所有提交的提交。



实际上,我喜欢让主人分支,哪些版本只提交。



在合并到master时,我应该保留所有提交的提交吗?或者你在合并之前压缩提交,然后再跟随Gitflow?

解决方案

在我看来,请记住,这是只是一个意见,你可能会得到不同的答案,你不应该在开发分支合并成master时压缩提交。这样做会失去很多已经发生的变化的历史。例如,几乎所有提交的提交都标有问题编号,这样就可以通过git历史记录回溯到提出的问题以及为什么进行更改。



更重要的是,您不应该直接从开发合并到主。假设你正在关注git-flow,那么这个过渡应该是通过一个发布分支完成的。



如果你问过在功能或修补程序分支上时是否应该承诺被压扁,那么这将是一个不同的答案。在这些情况下,可以说分支应该足够小,以保证只有一次提交,所以在这些情况下,我几乎总是在合并到目标分支之前重新绑定和挤压到一个单独的分支。


I am going to merge my release branch to master and I am wondering if I should squash the commits from develop into a single merge commit when merging into master.

General documentations about git flow contain figures like this one from in the Atlassian page:

In those figures only single commits appear on master instead of all commits made to develop.

Acctually, I like the idea of having a master branch which release commits only.

Should I retain all commits on develop when merging into master? Or do you squash the commits before merging to master when following Gitflow?

解决方案

In my opinion, and bear in mind, this is just an opinion, and you will likely get different answers, you should NOT squash the commits when merging into master from the develop branch. Doing so would lose a lot of the history of the changes that have been made. For example, almost all the commits I make are tagged with an issue number, so that there is full trace-ability back through the git history into the issues that were raised, and why changes were made.

More to the point, you shouldn't be merging directly from develop into master. Assuming you are following git-flow, then this transition should be being done through a release branch.

If you had asked whether, when on a feature or hotfix branch, should the commits be squashed then that would have been a different answer. In these cases, arguably the branch should be small enough to warrant only a single commit, so in these situations, I almost always rebase and squash commits into a single one, prior to merging into the target branch.

这篇关于Gitflow:我应该从发行版分支合并到主机时压缩提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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