Change old commit message to Git

I tried to change the old commit message as described here .

The thing is, now when I try to run rebase -i HEAD~5 , it says interactive rebase already started .

So I'm trying: git rebase --continue , but got this error:

 error: Ref refs/heads/master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba fatal: Cannot lock the ref 'refs/heads/master'. 

Any ideas?

+80
git git-rebase rebase repository
Dec 10 '09 at 22:16
source share
3 answers

It says:

When you save and exit the editor, it rewinds you to the last commit in this list and throws you on the command line with the following message:

 $ git rebase -i HEAD~3 Stopped at 7482e0d... updated the gemspec to hopefully work better You can amend the commit now, with 

It does not mean:

type git rebase -i HEAD~3 again

Try not to print git rebase -i HEAD~3 when exiting the editor, and it should work fine.
(otherwise, in your specific situation, git rebase -i --abort may be needed to reset everything and let you try again)




As Dave Vogt mentions in the comments, git rebase --continue intended to advance to the next task during the reboot process after you have made corrections to the first commit.

In addition, Gregg Lind mentions the reword git rebase command in his answer :

Replacing the pick command with the edit command, you can tell git rebase stop after applying this commit so that you can edit the files and / or the commit message, change the commit, and continue to rebase.

If you just want to edit the commit message for commit, replace the pick command with the reword , since Git1.6.6 (January 2010) .

It does the same as edit during the interactive reinstall, except it allows you to edit the commit message without returning to the shell . It is very useful. Currently, if you want to clear your commit messages, you should:

 $ git rebase -i next 

Then set all the commits for editing. Then on each of them:

 # Change the message in your editor. $ git commit --amend $ git rebase --continue 

Using ' reword instead of' edit allows you to skip git-commit and git-rebase .

+84
Dec 10 '09 at 22:37
source share

FWIW, git rebase interactive now has a "reword" option, which makes it much less painful!

+41
Jul 26 2018-10-10T00:
source share

You can do it as follows, as @gregg said to use the word reword

 git rebase -i HEAD~n 

Here n is a list of the last n commits.

For example, if you use git rebase -i HEAD~4

 pick e459d80 Do xyz pick 0459045 Do something pick 90fdeab Do blah blah blah pick 90fdeab Do pqr 

Now replace pick with reword for the commit you want to change.

  pick e459d80 Do xyz reword 0459045 Do something reword 90fdeab Do blah blah blah pick 90fdeab Do pqr 

Now close and save this, you will get the opportunity to edit the commit message for which you used reword in the following windows.

You can also specify an official document here

+4
Jul 25 '17 at 12:02 on
source share



All Articles