Post

Replacing an incorrect git commit message

If you have committed some code to git (or in the current case, BitBucket) and you have made an error in the commit message (in the current case, referenced the wrong Jira ticket), all is not lost.

To replace the commit message perform the following actions.

1
git commit -amend

Change the commit message, in my case;

1
2
FOO-1234 - fix the bar
 - add some stuff

to

1
2
FOO-1235 - fix the bar
 - add some stuff

Then all that is required is to do a push with --force

1
git push --force
This post is licensed under CC BY 4.0 by the author.