Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 协作
  6. 分支的工作流程
  7. Git 分支工作流程的示例
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Git 分支工作流程的示例

当然您需要创建最适合您团队的分支策略。但这里有一个快速示例,说明如何遵循涉及两种类型分支的分支策略工作流程:开发/集成分支和功能/主题分支。

假设当有人在生产中发现 bug 时,您正在开发一项新功能,并且您必须在开发新功能的同时修复该 bug。

On the way of work on a topic branch to add functions, it becomes necessary to fix bugs.

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

You can start working independently from the addition of functions by creating a new topic branch for fixing bugs.

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

You can make it public by including it in the original branch

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

You can go back to the original branch to continue working on the addition of functions

在功能分支上,您注意到需要提交“X”,即错误修复提交,才能继续执行新功能。换句话说,您必须将当前分支与开发分支上的更改同步。

有两种选择可以做到这一点:第一种是将包含提交“X”的开发分支与当前分支合并;第二个选项是将当前分支变基到包含提交“X”的开发分支。

对于此示例,您使用变基的方法。

Rebase a unified branch

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

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life