How to change git commit message
Apr 25, 2024
Update the latest commit
To update the latest commit, use the command:
git commit --amend
This will open an editor displaying the existing commit message, allowing you to modify it as needed.
Alternatively, you can directly replace the previous commit message with a new one using the -m
flag:
git commit --amend -m "New commit message"
For instance, if your last commit message was “Fixed a bug” and you want to change it to “Fixed a critical bug in the login feature,” you can use:
git commit --amend -m "Fixed a critical bug in the login feature"