Is there a way to change the comment of a particular old(not latest/one behind) commit which is already pushed to the remote repository in git? There are no changes in the content of the commit. I only need to change the comment which I made which is a total error!
Thanks
Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.
You can change the most recent commit message using the git commit --amend command. In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID--i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.
To just edit a commit message (without adding new changes to your last commit), just run the amend command without adding changes. Simple as that!
I'm not sure you're going to be able to if it's not the latest push. How do I edit an incorrect commit message in git (I've pushed)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With