简体   繁体   English

Gitflow:从发布分支合并到主分支时,我应该压缩提交吗?

[英]Gitflow: Should I squash commits when merging from a release branch into master?

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.我要将我的发布分支合并到 master,我想知道是否应该在合并到 master 时将来自 develop 的提交压缩为单个合并提交。

General documentations about git flow contain figures like this one from in the Atlassian page:关于 git flow 的一般文档包含来自 Atlassian 页面的类似这样的数字:

在此处输入图片说明

In those figures only single commits appear on master instead of all commits made to develop.在这些图中,master 上只出现了单个提交,而不是为开发所做的所有提交。

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?合并到 master 时,我应该保留所有关于 develop 的提交吗? Or do you squash the commits before merging to master when following Gitflow?或者你是否在遵循 Gitflow 时在合并到 master 之前压缩提交?

Link to the source article: Gitflow Workflow - Atlassian 原文链接: Gitflow Workflow - Atlassian

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.在我看来,并记住,这只是一种意见,你可能会得到不同的答案,当从开发分支合并到 master 时,你不应该压缩提交。 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.例如,我所做的几乎所有提交都标有问题编号,以便通过 git 历史记录可以完全追溯所提出的问题,以及进行更改的原因。

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.假设您正在关注 git-flow,那么这个转换应该通过一个发布分支来完成。

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.在这些情况下,可以说分支应该足够小以保证只进行一次提交,因此在这些情况下,我几乎总是在合并到目标分支之前将提交变基和压缩为单个提交。

The master branch is used to maintain a record of releases, so each commit should represent a squashed set of changes from the development branches that made up the release build. master 分支用于维护发布记录,因此每次提交都应代表来自构成发布构建的开发分支的一组压扁的更改。

Squashing the commits makes it much easier to see what changes went into a release and to create hotfix branches from a release commit when necessary.压缩提交可以更容易地查看发布中的更改,并在必要时从发布提交创建修补程序分支。 Tag each squashed commit with the release version number.用发布版本号标记每个压缩的提交。

If you squash merge between develop, a release branch and master it gets very hard to merge a change to a release branch back to develop without file conflicts.如果您在开发、发布分支和主分支之间压缩合并,则很难将发布分支的更改合并回开发而不发生文件冲突。 It's also hard to merge a hotfix to develop, then merge develop through a release back to master later.将修补程序合并到开发中,然后通过发布将开发合并回主版本也很困难。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将其合并回gitflow的master后,是否应该删除开发分支? - Should I delete the development branch after merging it back into the master in gitflow? Gitflow:合并要开发的修补程序分支进行到母版的合并提交 - Gitflow: Merging hotfix branch to develop carries merge commits made to master 在Git中,当推送master分支时,来自开发分支的提交也被推送。 这应该发生吗? 我正在使用Gitflow - In Git when pushing the master branch, commits from the development branch are pushed too. Is this supposed to happen? I am using Gitflow 从master分支中提取其他提交后,Git squash提交 - Git squash commits after pulling other commits from master branch GIT:如果我将所有提交压缩到一个分支上然后合并到master上,那么与master进行的先前合并会发生什么? - GIT: What happens to previous merges from master if I squash all commits on a branch and then merge it onto master? Gitflow:将发布错误修复合并回主开发 - Gitflow: Merging release bugfixes back to develop from master 壁球在主节点上提交,但在功能分支上单独提交? - Squash commits on master but separate commits on feature branch? Git:如何从一个分支到另一个主要的提交和压缩提交? - Git: How to rebase and squash commits from branch to master? 从master合并后的Squash功能分支提交 - Squash feature branch commit after merging from master 发布后 Gitflow 在 master 后面开发分支 - Gitflow develop branch behind master after a release
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM