Your new commit graph has another X
commit because rebase does not preserve merges by default. If you wanted to preserve merges, you need to use the --preserve-merges
flag, or -p
for short:
git rebase -i -p <base-commit>
Note that preserving merges interactively does not work correctly when you reorder commits. It's OK to use them together otherwise:
The todo list presented by
--preserve-merges
--interactive
does not represent the topology of the revision graph. Editing commits and rewording their commit messages should work fine, but attempts to reorder commits tend to produce counterintuitive results.
Also, are you sure that X
was the base commit you wanted to use? If you wanted to amend X
, I think you should have chosen a
as the base instead:
git rebase -i -p a