Changing a git commit message

Posted November 10, 2020 766 views

I recently got asked if there is a way to change the commit message we just entered in git.

If a commit message contains unclear, incorrect, or sensitive information, you can amend it locally and push a new commit with a new message to GitHub. You can also change a commit message to add missing information.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


I will recommend everyone to navigate to github official docs and change the following article:

There are several cases which are all covered in the official document page.

An example is to amend a message that has not been pushed online yet. You need to navigate to you local repository that contains the commit you want to change. In your terminal client type the following command:

git commit --amend

You can now edit the commit message in the text editor and save the commit.

The other scenario is to edit the most recent commit message. You can achieve that using the exact same command:

git commit --amend

Changing the commit message will create a new commit to replace the old one.

Hope that this helps!