Change commit messages of past Git commits

Posted . Visible to the public.

To change a commit message of the most recent (unpushed) commit, you can simply use
git commit --amend -m 'new message'

To change messages of (unpushed) commits further in the past:

git rebase -i [COMMIT BEFORE THE FIRST YOU WANT TO EDIT]

Mark all messages to be changed with "edit".

Git will start the rebasing and stop at every marked commit. For each of those, do a
git commit --amend -m 'new message'
git rebase --continue

Profile picture of Tobias Kraze
Tobias Kraze
Last edit
Keywords
history, manipulate, rewrite
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2010-11-23 14:51)