• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Change Git Commit Message

Written by Rahul, Updated on November 7, 2020

Its always good to add a proper message with each git commit. These commit messages help you and other users to understand the purpose of any specific commit. Sometimes you add a wrong commit message and want to edit commit message.

This tutorial help you to how to change last commit message in git repository.

Change Git Commit Message

Here you may have 2 situations. One you may have pushed your commit to remote repository or second you have not pushed your commit.

Follow the below instructions based on your pushed commit or not.

I have not Pushed Commit

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.

I have Pushed Commit

Okay, no problem here, You can still update commit message. But its not recommended option to change message of pushed commit. In this situation, you have to push your changes again to remote server forcefully.

First, change the commit message on your local repository.

git commit --amend -m "Your updated commit message" 

Then push your changes to remote origin with --force option.

git push origin master --force 

Here we assume, that origin is your remote repository and your are pushing changes to master.

Conclusion

The conclusion is that use the git commit –amend command to change message of your last commit.

Hope this tutorial helped you to change git commit message. If you found any better solution to handle this situation, Please add a comment below.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy