Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»How to Change Git Commit Message

    How to Change Git Commit Message

    RahulBy RahulSeptember 9, 20152 Mins ReadUpdated: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.

    commit git
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Setup A Firewall with UFW on Ubuntu & Debian
    Next Article How to Create Disk Partitions in Linux

    Related Posts

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    How to Git Stash Changes

    Updated:October 29, 20213 Mins Read

    How to delete Git tags

    Updated:October 25, 20211 Min Read

    How to Create Git tags

    Updated:October 25, 20212 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.