0

When I'm doing git rebase -i, I have an option to squash my commits into one.

What I normally do is change the 1st commit message and squash the rest of the commits.

After that I'm presented with a screen that tells me to:

Please enter the commit message for your changes.

Is there a way to use only the one commit message I decided in the previous step?

Ace
  • 831
  • 2
  • 8
  • 28
  • 1
    If your goal is to edit the message only once, why don't you just squash in the rebase then do that edit at the end? – jonrsharpe May 02 '21 at 11:21
  • Does this answer your question? [How do I keep the commit message when editing commits via git rebase --interactive?](https://stackoverflow.com/questions/10832722/how-do-i-keep-the-commit-message-when-editing-commits-via-git-rebase-interacti) – k0pernikus May 02 '21 at 12:17

1 Answers1

3

When the editor opens, it should give you a comment describing the available commands which (among other things) contains:

# r, reword <commit> = use commit, but edit the commit message
# f, fixup <commit> = like "squash", but discard this commit's log message

It sounds like you just want to use f to "fixup" the commit.

In other words, in the editor, don't change the first column of the commit you wish to keep (or perhaps change it to r), and change the first column of the commits you wish to squash to f.

William Pursell
  • 204,365
  • 48
  • 270
  • 300