How do I change a git commit message in Bitbucket?

I need to change an old git commit message in Bitbucket. I tried git rebase -i and reworded my message, but when I pulled and committed it just kept the old message in Bitbucket and merged my changes in.


It's basically 4 step process. But a bit risky if multiple team member are working on the same branch and have their own copies. (If you are the only one working on it, go for it)

This git manual explains it beautifully: Amending older or multiple commit messages

  1. git rebase -i HEAD~X (X=No of commit messages you want to change)
  2. Above command will open git file in editor. There replace text 'pick' with 'reword' and save the file.
  3. It will open editor for every commit one by one, there you again change the commit message.
  4. At the end: git push -f

If it is the most recent commit, you can simply do this in 2 steps:

  1. git commit --amend -m "modified commit message" (amend message)
  2. git push --progress origin --force (force push)

Be careful using --force or -f! Bad things might happen...

Force pushing is strongly discouraged since this changes the history of your repository. If you force push, people who have already cloned your repository will have to manually fix their local history.

IMHO you can force push to a branch if you're absolutely sure that nobody else checked out the amended commit before your push.

And here you can find documentation on git commit and git push.