In Git, how do I edit the description of a commit already made?


In case you need to change the description of a commit , to make the description clearer, or specify which issue it is linked to.

I would like to know how do I edit the message that accompanies the commit , after it has been executed.


It's Quiet Guilherme, do the following

git commit -m "Nova mensagem que vai substituir a anterior" --amend 

This will overwrite your old commit message!

And even if the commit is not the last one, you can edit an old commit using the interactive commit mode

git rebase -i

It is also useful if you have made any changes and want them to be part of the previous commit !

for example: You made a commit to close issue X, but saw that something was missing, performed this operation, but you don't want to have two commits closing the same issue, so you merge the two into a single commit using amend

Oh and this only works fine if you haven't push this commit yet

Scroll to Top