Change a Commit Message Before It Has Been Pushed
March 20, 2020
git
Amend the Most Recent Commit Message
The most recent commit's message can be modified by using the commit --amend
command.
Open an Editor to edit the commit message
ssh
1.git commit --amend
This will open up an editor with the previous commit message that you can edit to something else. Usually the editor will have comments about what will be committed, to what branch, and the date of the original commit.
Example
ssh
1.> git commit --amend
bash
1.Add NPM open package to home page2.3.# Please enter the commit message for your changes. Lines starting4.# with '#' will be ignored, and an empty message aborts the commit.5.#6.# Date: Thu Mar 19 18:26:41 2020 -07007.#8.# On branch master9.# Your branch is up to date with 'origin/master'.10.#11.# Changes to be committed:12.# new file: content/nano/npm/2-open-package-home-page.md13.#
Modify Commit message in the command line
bash
1.git commit --amend -m "Updated message"
The -m
command will directly set the commit message in the same way running git commit -m "message"
directly sets the message when creating the commit.