単純にgit rebase branch
すると、現在のツリーにあるマージコミット(Merge commits)は消失してしまいます。これを避けるためには、Preserve Merges
オプションを使います。
git rebase --preserve-merges {branch_name}
-p
として省略することもできます。
git rebase -p {branch_name}
マニュアルの引用
-p
--preserve-merges
Recreate merge commits instead of flattening the history by replaying commits a merge commit introduces. Merge conflict resolutions or manual amendments to merge commits are not preserved.
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).
マージコミットが導入したコミットを再生して履歴を平坦化するのではなく、マージコミットを再作成します。マージ競合解決またはマージコミットの手動修正は保存されません。
これは--interactive機構を内部的に使用しますが、--interactiveオプションと明示的に組み合わせることは、あなたが何をしているのか分からない限り、一般的には良い考えではありません(以下のバグを参照)。