What is the command to change the last commit message?
Posted by SamPetr
Last Updated: July 15, 2024
To change the last commit message in Git, you can use the following command:
git commit --amend -m "New commit message"
This command opens the last commit and allows you to replace the commit message with "New commit message". Keep in mind that if you've already pushed this commit to a remote repository, you'll need to use git push --force to update the remote commit, as it rewrites history. Be cautious when force-pushing to shared branches, as this can disrupt other collaborators' work.