Git 分支工作流程的示例
当然您需要创建最适合您团队的分支策略。但这里有一个快速示例,说明如何遵循涉及两种类型分支的分支策略工作流程:开发/集成分支和功能/主题分支。
假设当有人在生产中发现 bug 时,您正在开发一项新功能,并且您必须在开发新功能的同时修复该 bug。

在开始修复 bug 之前,您先从开发分支创建一个新分支。这个新分支将修复 bug 与您正在处理的新功能隔离开来

当准备发布修复 bug 时,将修复 bug 功能的分支合并到开发分支中。

然后切换回原来的功能分支,并继续处理新功能。

在功能分支上,您注意到需要提交“X”,即错误修复提交,才能继续执行新功能。换句话说,您必须将当前分支与开发分支上的更改同步。
有两种选择可以做到这一点:第一种是将包含提交“X”的开发分支与当前分支合并;第二个选项是将当前分支变基到包含提交“X”的开发分支。
对于此示例,您使用变基的方法。

一旦您在当前工作树中有了“X”,您就可以再次安全地开始使用新功能。