33.13 Git Commit Message Edit


You may find that you have some old commit messages that have been pushed to the repo that need changing. To do so, rebase your local repository with a collection of the previous commit messages, identify those that need to be reworded, edit the new commit messages and force a commit.

To rebase your local repository with the last 10 commits:

git rebase -i HEAD~10

An editor will pop up with a line for each of the commit messages and the commentary on what to do. For and IDE you will probably go to a commit message line that you want to change and type r to reword that message. Do this for each commit message to be updated.

After exiting from the editor a new editor will open for each commit message that was marked to be reworded. Edit the message and save and exit the editor.

Be sure to then commit any current changes. Then:

git commit --amend -m "New commit messages."
git push --force HEAD

The updated commit messages should then appear in the remote repository.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0