【问题标题】:How to create releases on master using squashed merges如何使用压缩合并在 master 上创建发布
【发布时间】:2019-09-29 04:11:43
【问题描述】:

我们使用 master/staging/feature 分支策略。 master 和 staging 是长期存在的,并且功能分支只存在于与 staging 合并之前。

当将 staging 合并到 master 中时,我们的 jenkins 服务器会压缩提交以在 master 中创建一个带有版本标记的“发布”提交。

不幸的是,一些更改被遗漏了,即在功能分支中删除的文件仍然存在于 master 中。

我们希望 staging 拥有完整的提交历史,而 master 只拥有一个带有版本号标记的提交。

我知道问题在于压缩提交和缺乏共享历史记录,我的问题是如何在 master 上实现单次提交,并 自动 暂存完整历史记录(这必须发生在詹金斯服务器上)。

我已经查看了 rebase,但我不知道它是否可以自动执行我们想要的操作(这必须在 jenkins 服务器上进行,无需人工干预)。

【问题讨论】:

标签: git branching-and-merging branching-strategy


【解决方案1】:

您可以使用 reset --soft 来实现这一点,以便分支“相同”。因此,您在 master 上完成了最后一个版本(此时 staging 和 master 是“相同的”)。然后在功能分支上发生 1000 次提交并合并到暂存。此时你想再次在 master 上释放:

git checkout --detach staging
git reset --soft master # here is where the magic happens... all changes between master and staging are placed on index, branch pointer is set to master
git commit -m "New release" # if you want to have a more detailed comment, find the way to do it.
git branch -f master # move master pointer to new revision
git tag blahblah # tag revision or take it from here and do whatever you need

不涉及合并。在流程结束时,分支将相同

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-21
    • 1970-01-01
    相关资源
    最近更新 更多