我正在尝试按照说明编辑旧的提交消息 here .
现在,当我尝试运行 rebase -i HEAD~5
时,它说 interactive rebase already started
。
然后我尝试:git rebase --continue
但是得到这个错误:
error: Ref refs/heads/master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba
fatal: Cannot lock the ref 'refs/heads/master'.
有什么想法吗?
最佳答案
它说:
When you save and exit the editor, it will rewind you back to that last commit in that list and drop 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
这并不意味着:
type again
git rebase -i HEAD~3
尝试在退出编辑器时不要输入git rebase -i HEAD~3
,它应该可以正常工作。
(否则,在您的特定情况下,可能需要 git rebase -i --abort
来重置所有内容并允许您重试)
作为Dave Vogt在评论中提到,git rebase --continue
用于在 rebase 过程中进行下一个任务,在您修改了第一个提交之后。
此外,Gregg Lind在 his answer 中提到git rebase
的 reword
命令:
By replacing the command "pick" with the command "edit", you can tell
git rebase
to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.If you just want to edit the commit message for a commit, replace the command "
pick
" with the command "reword
", since Git1.6.6 (January 2010).It does the same thing ‘
edit
’ does during an interactive rebase, except it only lets you edit the commit message without returning control to the shell. This is extremely useful.
Currently if you want to clean up your commit messages you have to:
$ git rebase -i next
Then set all the commits to ‘edit’. Then on each one:
# Change the message in your editor.
$ git commit --amend
$ git rebase --continue
Using ‘
reword
’ instead of ‘edit
’ lets you skip thegit-commit
andgit-rebase
calls.
关于git - 使用 `git rebase` 更改旧提交消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1884474/