Git: Changing your last commit message
NicolasBrondinBernard
A mistake, a typo? A simple command to fix the situation!

Article published on 26/07/2021, last updated on 10/08/2026
If you use Git regularly, then you've surely already created a commit containing a spelling mistake, or with a message that doesn't really match the changes made...
If that's the case, you'll see that editing the message of your last commit is child's play!
How do you do it?
The command below will let you simply edit the last commit message, in a text editing interface right inside your terminal:
$ git commit --amend
If you need to edit the last X commits, then I'd recommend undoing them so you can recreate them, the whole process is explained in this previous article:
If the commit has already been pushed to the remote repository
A simple Git push wouldn't be enough to refresh the new commit message, because the project's history has been modified outside of Git's usual cycle.
You'll therefore need to add a "--force-with-lease" parameter, which will let you force the update, without impacting subsequent commits if they're already present.
$ git push --force-with-lease
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
Annuler un ou plusieurs commit facilement avec Git - Nicolas Brondin-Bernard
No comments yet