git – How to change the message of a commit?

Question:

I just did a commit:

git commit -m "este es un comentario"

However, I have suddenly realized that this message is not correct. Can I modify it? If yes, how?

If I rewrite git commit -m "un nuevo comentario" will do another commit instead of modifying the one I already did.

Answer:

The quickest and most practical option is to use:

git commit --amend

After which the editor will open so you can modify the message.

If you want to write something totally new, you can directly say:

git commit --amend -m "Este es el nuevo comentario"

You can see more details in the answer in the English version to Edit an incorrect commit message in Git .

Scroll to Top