You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Github分支仅允许Squash and Merge合并方式?

配置GitHub分支仅允许「Squash and Merge」合并方式

完全可以给指定分支(比如你的develop分支)配置仅允许Squash and Merge的合并规则,操作步骤如下:

  • 进入目标GitHub仓库的「Settings」页面
  • 在左侧菜单选择「Branches」
  • 找到对应develop分支的分支保护规则,点击「Edit」;若还未创建规则,点击「Add rule」新建
  • 滚动到「Merge requirements」区域,勾选「Allow specified merge methods」选项
  • 仅保留「Squash and merge」的勾选状态,取消「Create a merge commit」和「Rebase and merge」的勾选
  • 页面底部点击「Save changes」保存配置

配置完成后,所有向develop分支提交的PR只能通过Squash and Merge完成合并,其他合并方式会被禁用,彻底避免零散提交污染分支历史。

内容的提问来源于stack exchange,提问作者Brad Parks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 12:02:17