Git commit --amend without requesting a message

From time to time I find myself correcting using the same message.

Typically, I do:

  • Add changes to the staging area.
  • Do git commit --amend .
  • Wait for the text editor to open.
  • Save and close it (without changing the message).

In any case, to tell git that I don't want to change the commit message (skip the step of opening a text editor and save the message)? How:

  • Add changes to the staging area.
  • Tell git to change my staging area to the last commit without asking for another message.



I know that I can avoid git starting my text editor by doing git commit --amend -m "<message>" . But that way I would have to retype the message.

+47
git git-commit amend
Mar 18 '13 at 14:44
source share
2 answers

Try git commit --amend --no-edit .

+83
Mar 18 '13 at 14:49
source share

This will change the last commit, using the same message, in one command:

 git commit --amend -C HEAD 
+11
Mar 18 '13 at 14:53
source share



All Articles