在比我认为合理的时间更长之后,我就能够在irc上找到一个解决方案:
git rebase -i -m -r firstCommitInBranch^
做我需要的事。
从Git文档:
-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.
(...)
The --rebase-merges mode is similar in spirit to --preserve-merges, but in
contrast to that option works well in interactive rebases: commits can be
reordered, inserted and dropped at will.
和
-m, --merge
Use merging strategies to rebase. When the recursive (default) merge strategy is
used, this allows rebase to be aware of renames on the upstream side.
我还错过了文档中说不使用的部分
-p
一起
-i
以下内容:
-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).