It is a good idea to add proper comments with the each commit of code to git repository. Think, If you have added some wrong comment with your last commit. Now, you want to change your last commit message. This tutorial will help you to change last commit message in Git repository.
Change Last Commit Message in Git
We can update last commit log using
--amend option in git commit. Use the following command to do it but remember that if some other has already sync your changes then they again need to sync your code to avoid any future problems related to this.
git commit --amend-m "Your updated commit message"
This will change the last commit message in your local repository. But if you have already pushed your changes to remote branches, Then you also need to push your changes again to remote server forcefully.
For example, you need to push changes in the master branch of remote origin.
git push origin master --force
Hope this tutorial is helpful for you. If you found any better solution to handle this situation, Please don’t forget to add your comment.