Change Commit Message In Git Updated on December 9, 2021 by Christopher Maiorana 2 Minutes, 16 Seconds to Read As you may already be aware, committing the state of your project with a git commit records any changes (additions or deletions) to the official project history. And every “commit” prompts you for a brief message, in which you will notate what happened in that commit. (For more detailed information, you might want to write Git notes.) But what if you need to go back, change commit message, or “amend”, an entire commit to include or exclude file contents? There is an option for that. Is --amend Or reset Better?Change Commit Message Using “Amend”Using --amend To Change Files In Commit If you don’t need cPanel, don't pay for it. Only pay for what you need with our scalable Cloud VPS Hosting. CentOS, Debian, or Ubuntu No Bloatware SSH and Root Access Is --amend Or reset Better? The default application of --amend simulates a reset followed by a another commit. Using “amend” instead of a reset saves you the step of having to do a reset. Plus, resets can be destructive if you use the wrong option. With an --amend you can safely change the most recent commit without daring a reset. Change Commit Message Using “Amend” By default, the --amend option will apply your changes to the previous commit, or the “tip” of the branch. (“Tip of the branch” refers to the most recent commit regardless of which branch you are on. Make sure you are amending a commit on the correct branch.) This is why “amend” is a great option to use if you simply forgot something, want to make a quick change, or just want to otherwise alter what you just committed without having to create a new commit. Just run this command: git commit --amend And you will be prompted to edit your most recent commit in your text editor of choice. You will also notice that the previous commit message is printed into the text editor. This is normal. You can edit the message or erase it and write a completely new message. Or, if you want to bypass the text editor, you can use the -m option and put your new commit message in quotes. git commit --amend -m "New commit message" Using --amend To Change Files In Commit It’s easy to also change the contents of the files in the commit by using the --amend option. All you need to do is edit the files as you desire, stage them as usual, and run the commit again with the --amend option as you did above. As a side note, you may also want to check your work by running: git status This command will let you know which files you just edited and whether or not they are staged for commit. In order to include any changes in the recent commit, they will need to be staged (just as in a regular commit). Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles How to Host a Static Site with GitHub Pages Publish Your Lovable Created React WebApp to InMotion Hosting Shared Hosting via GitHub How to Publish Your Lovable Created React WebApp to UltraStack ONE for React Git Checkout Command – How To Switch To Branches and Commits How to Create Your Own Git Server Using Git to Publish Files How to Create a New Account with GitHub How to Commit Changes in Git How to Sign Tags and Commits with Git Git Fundamentals Complete Beginner Guide