I found a simple soloution!
git commit --amend -m "New commit message"
My approach to edditing a commit message is to do an interactive rebase with the command git rebase -i HEAD~3
.
This allows to change all commit until the specified commit (in this case 3 commits behind head, you can also give the SHA-1 hash of a commit instead of a number behind HEAD.
Afterwards, notepad opens where the commits are shown in order. There you can edit all commit messages as well as squash commits into the previous.
A more detailed description can be found here [1]
I would go with the --amend command, just remember that you then need to force that push (-f). So if someone already pulled your old commit they would have to rebase their work onto your new commit, but if you are only changing the message it's really not a problem but good to keep in mind.
I would also do it with the --amend command
Hi, I had this problem already a few times, a good source for IntelliJ is: https://www.jetbrains.com/help/idea/edit-project-history.html#reword-commit
Even after pushing the commit, it is possible to change the message.
If you have not pushed yet this is a solution (for IntelliJ):
• Right-click the commit whose message you want to edit in the Log tab of the Git tool window Alt+9 and select Edit Commit Message from the context menu, or press F2.
• In the dialog that opens, enter a new commit message and click OK
You can also use the "git commit --amend" command.
I hope this helps!
Comments