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.

- 16,038
- 10
- 74
- 104

- 46,433
- 78
- 254
- 460
-
Are you found solution? – asolovyov Apr 05 '13 at 18:06
-
@MonkeyBonkey You can accept the correct answer if you want. – Dchris Mar 28 '17 at 13:09
-
1Possible duplicate of [Changing git commit message after push (given that no one pulled from remote)](https://stackoverflow.com/questions/8981194/changing-git-commit-message-after-push-given-that-no-one-pulled-from-remote) – naXa stands with Ukraine Mar 26 '18 at 00:05
3 Answers
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
git rebase -i HEAD~X
(X=No of commit messages you want to change)- Above command will open git file in editor. There replace text 'pick' with 'reword' and save the file.
- It will open editor for every commit one by one, there you again change the commit message.
- At the end:
git push -f

- 35,493
- 19
- 190
- 259

- 5,031
- 1
- 30
- 28
-
-
jadav Bheda I tried this solution and could not edit vim file. Even took help of this https://vim.rtorr.com/ cheat codes. I almost corrupted that file.I mistakenly changed code written after 'pick' Would that cause trouble? Please help. – Always_a_learner Jun 25 '18 at 09:59
-
-
If it is the most recent commit, you can simply do this in 2 steps:
git commit --amend -m "modified commit message"
(amend message)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.

- 35,493
- 19
- 190
- 259
-
I've tried this, but it did not seem to change the commit message for me. :( – Steve Horvath Jan 21 '21 at 22:01
-
@SteveHorvath I can help you to debug the problem. I assume that you followed the above steps, and the root cause of your problem lies in one of the following stages. 1. what command did you type? 2. what feedback did you get (error / success messages)? 3. how did you check that the commit message is changed? – naXa stands with Ukraine Mar 18 '21 at 17:38
I don't know if you can change the commit message but you can make a comment under your commit message.I think this is somehow a change in your comment. You click on your commit message's number and beneath your message you can make any comment you want. Then a "K1" sign will appear next to your message which means that you have one comment in your message which will remind you that you changed your message... I hope this will help you...

- 2,867
- 10
- 42
- 73