1

I'm working with a branch with a fairly large number of commits and would like to do an interactive rebase to condense it into fewer commits before merging to master. In order to avoid weird conflicts, I'm trying to maintain a certain order to the commits where possible, but sometimes need a commit message to be maintained in a long string of fixups. In other words, I have something like:

pick abc123 commit A
f jkl567 commit B
f def345 commit C
s mno789 commit D
f xyz901 commit E

Will the message from the squash commit still be preserved on the first picked commit or will it do something like squash 'commit D' into commit C and then end up dropping the commit message when commit C gets "fixed up" into commit B and then into commit A?

2 Answers2

2

Git is doing it in order one by one so it will:

  1. Fix up with B, keeping commit message from A
  2. Fix up the new commit with C, keeping commit message from A
  3. Squash with D, asking to edit message from A+D
  4. Fix up with E, so keeping the version you saved in 3.)
Philippe
  • 28,207
  • 6
  • 54
  • 78
0

From my experience, you will get an editor for the commit message after the squash commit is finished. By default, the editor has all commit messages from all commits being squashed. You can then edit the message as you see fit.

TL;DR However git computes a suggested commit message, you will be given the opportunity to edit it before the commit is finally committed.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • That makes sense. I forgot about the commit editor phase of the rebase. Thanks! I would upvote you if I had the reputation to be able to. P.S. I feel bad for anyone that needs a TL;DR for a 3 line explanation :) – Chris Merrill May 16 '18 at 21:59