For anyone looking for a Windows/Mac GUI to help with editing older messages (i.e. not just the latest message), I'd recommend Sourcetree. The steps to follow are below the image.
For commits that haven't been pushed to a remote yet:
- Make sure you've committed or stashed all current changes (i.e., so there are no files listed in the "File Status" tab) - it won't work otherwise.
- In the "Log / History" tab, right click on the entry with an adjoining line in the graph one below the commit(s) you wish to edit and select "Rebase children of interactively..."
- Select the whole row for a commit message you wish to change (click on the "Message" column).
- Click the "Edit Message" button.
- Edit the message as desired in the dialog that comes up and then click OK.
- Repeat steps 3-4 if there are other commit messages to change.
- Click OK: Rebasing will commence. If all is well, the output will end "Completed successfully". NOTE: I've sometimes seen this fail with
Unable to create 'project_path/.git/index.lock': File exists.
when trying to modify multiple commit messages at the same time. Not sure exactly what the issue is, or whether it will be fixed in a future version of Sourcetree, but if this happens would recommend rebasing them one at a time (slower but seems more reliable).
...Or... for commits that have already been pushed:
Follow the steps in this answer, which are similar to above, but require a further command to be run from the command line (git push origin -f
) to force-push the branch. I'd recommend reading it all and applying the necessary caution!