Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 协作
  6. 整合分支
  7. 将分支变基
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

将分支变基

要获得更清晰的修订历史记录,您可以使用 git rebase 命令来整合您的分支。

假设我们有两个具有非快进合并场景的分支。

Branch

变基将导致分支历史记录看起来类似于下面的示例。

Unify branches by using rebase

当您将bugfix分支变基到主分支时,来自bugfix分支的提交将被重播并附加到主分支的末尾。结果是bugfix分支历史记录中的单个简单提交串流。

如果在附加提交时发生冲突,Git 会要求您解决冲突,然后再继续对其他提交进行变基。

Unify branches by using rebase

变基不会移动main的位置。在任何情况下,您都可以在变基后进行快进或从bugfixmain的干净合并。

Unify branches by using rebase

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life