1

Consider the following series of commits on the local branch:

5 Correction of something meaningless, again !
4 Business correction n°3
3 Correction of something meaningless
2 Business correction n°2
1 Business correction n°1

I want to squash 5 with 3 in order to have:

4 Correction of something meaningless, squashed !
3 Business correction n°3
2 Business correction n°2
1 Business correction n°1

Can I do that with the interactive rebase ? From what I have seen (ex: https://www.internalpointers.com/post/squash-commits-into-one-git) and tested so far, I can only squash 5 with a series of direct commits, like:

  • 4
  • 4 3
  • 4 3 2
  • 4 3 2 1
Flyout91
  • 782
  • 10
  • 31
  • 1
    Pardon my remark, but aren't you trying to transform something useless (noisy commit info) but truthful (because it **is** history) into something useless *and* deceiving? If the goal is history clarity, you're just constructing a (not that) pretty lie. – Romain Valeri Sep 19 '19 at 14:41
  • I don't see how history clarity is a lie or deceiving. Commits 5 and 3 concern the same kind of things (meaningless things from a buisiness point of view), so they shoud be grouped together. – Flyout91 Sep 19 '19 at 15:14

1 Answers1

3

You can do it with interactive rebase.

Just reorder the lines like that when prompted by git:

squash 5 Correction of something meaningless, again !
pick 3 Correction of something meaningless
pick 4 Business correction n°3
pick 2 Business correction n°2
pick 1 Business correction n°1

But, because you change the order, conflicts could happens and sometimes that don't worth rewriting the history...

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • It works. I did not see I could move commits! This is indeed prone to conflicts, thanks for the advice. – Flyout91 Sep 19 '19 at 15:10