Skip to content

editing a Git commit message

Note

  • foobar represents the forty-character commit object name of the commit to be edited.

Make sure all unstaged changes are committed or stashed, then use git rebase -i foobar^ to open the default text editor with a list of commits. Using the first seven digits of the forty-character commit object name, identify the line with the commit message to be edited, then change the default pick action to reword. One or more commit objects can be speficied in this way. Save the file and quit the text editor. The editor will then be reopened with an option to edit the specified commit message. Edit the commit message, then save the file and quit the text editor. The command prompt will reappear, and a new tree will exist with the updated message.

licensing

Some rights reserved: CC BY-SA 3.0. Includes significant content from an answer on Super User by Mureinik, with changes made.