git rebase -i --rebase-merges HEAD~3

Category: Git - Advanced

git rebase -i --rebase-merges HEAD~3

Rebase while preserving merge commits

Interactive rebase normally flattens merges away; --rebase-merges keeps the merge structure and re-creates the merge commits on the new base. It is essential for rebasing branches with intentional merge topology. Conflicts may need to be re-resolved at each merge.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.