I don’t quite understand how the commits are squashed with git rebase -i. There is one thing I was left wondering:
If my rebase -i produces this list:
pick A Last commit
pick B Commit
pick C Some other commit
Should I squash commits A and B or B and C? Problem is git said in this case that it would rebase D..A onto D (D being the last commit before this) rather than C..A onto C which would make sense to me. D is not shown at all, so why word it like that?
The thing is that
D..Ain git terminology means “from D to A not including D itself”. If you look intogit-rev-listmanual page, you’ll see thatwhich means “list all commits that are included in
<commit2>, but are not included in<commit1>. And the changes made byDitself are included inDcommit. So it’s not included in list denoted asD..A.That’s why it’s correct to say that
git rebase -i DaffectsD..HEAD.