If I have the following history
A-B-C-D-E-F-G
A is root commit and I want to squash A-D, but keep E unchanged, I found a way to do it in 2 steps
git rebase --onto A C
then it becomes
A-D'-E-F-G
then I do a
git rebase -i --root
and in vim I interactively set D' to be s
, then I can get what I want
A'-E-F-G
which A'
has all the changes from A-B-C-D, while E
is still the original E
( its diff does not change)
Can I do above in a simpler way ? could it be done in some magic --onto
command in one git command ? ( non interactively) Because in the real example, I have a few hundred of commits instead of just A-B-C-D here.