如何保留--no-ff在rebase之后合并

时间:2014-10-29 12:49:01

标签: git merge git-merge rebase git-rebase

假设您有masterdevelop个分支机构。更进一步,假设您的工作流程是这样的:

  • develop您签出了新的feature分支机构;
  • 继续努力;
  • 再次查看develop;
  • feature分支与--no-ff合并。

通过这种方式,您可以很好地了解哪些提交属于哪个功能。

* Merge branch 'feature' into develop
|\
| * Commit 3
| * Commit 2
| * Commit 1
|/
* Some old commit

在某些时候,你拉master并想要在其上重新develop。但是,在rebase git log以线性方式显示develop上的所有提交之后,没有显示feature分支并省略通用合并提交:

* Commit 3
* Commit 2
* Commit 1
* Some old commit

为什么会这样,如何在变基后保留它们?

1 个答案:

答案 0 :(得分:3)

在Git 2.18之前,将-p传递给git rebasepreserve merges

-p
--preserve-merges

    Instead of ignoring merges, try to recreate them.

    This uses the --interactive machinery internally, but combining it with the --interactive option explicitly is generally not a good idea unless you know what you are doing (see BUGS below).

使用Git 2.18,使用-rrebase merges

-r
--rebase-merges[=(rebase-cousins|no-rebase-cousins)]

    By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With --rebase-merges, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually.

此选项不再受交互式rebase的上述限制,并且“可以随意重新排序,插入和删除提交”。

相关问题