Change the commit message of my last commit

Share this video with your friends

Social Share Links

Send Tweet

Did you make a typo in your last commit message? No problem, we can use the git --amend command to change it very easily. Note: This only holds if you did not yet push your changes to the remote repository

Instructor: [00:00] On my local master branch here, I made a change to our Readme file. I just added a couple of lines. We want to commit them.

[00:08] We do usually git add. We do the git commit -m add credit section. Before we just put it up on to our remote repository, we recognize that we actually made a mistake. Let's say we have a normal naming convention that in front of every commit we use what type of contribution it is.

[00:29] However, we have already committed that to our local master branch and we want to change [inaudible] commit message. What we can do is to simply use the git commit --amend command. If I hit enter, I am going into that editing mode again, and I can just adhere the line. Save again.

[00:49] Now you can see that the commit message has been changed. It's very important to note here that we shouldn't do that whenever we have already synchronized the change with the remote repository because, again, we are changing here the ID of our commit. Therefore, we will break again the merges with [inaudible] people.