在Git上更改旧的提交消息 [英] Change old commit message on Git
问题描述
我试图编辑旧的提交消息,如此处所述。
现在,当我尝试运行 rebase -i HEAD〜5
时,它表示交互式rebase已经开始。
然后我尝试: git rebase --continue
但是得到这个错误:
error:Ref refs / heads / master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba
致命:无法锁定ref'refs / heads / master'。
有什么想法?
当你保存并退出编辑器时,它会将你倒回到最后一次提交该列表在命令行中放入并显示以下消息:
$ git rebase - 我HEAD〜3
停在7482e0d ...更新了gemspec,希望能够更好地工作
现在可以用
不代表:
再次输入
git rebase - 我的头〜3
尝试 不是 在退出编辑器时输入 git rebase -i HEAD〜3
,它应该可以正常工作。
(否则,在您的特定情况下, code> git rebase -i --abort 可能需要重置所有内容并允许您重试)
$ hr
As Dave Vogt 在评论中提到, git rebase --continue
用于转发下一个任务在你修改第一次提交之后 。
另外, Gregg Lind 在他的提及回答 reword
命令 git rebase
:通过替换
$ b
使用命令编辑命令pick,可以告诉git rebase
在应用该提交后停止,以便您可以编辑文件和/或提交消息,修改提交并继续重新绑定。
如果您只想编辑提交的提交消息,请将命令
选择
命令rew ord
,因为 Git1.6.6(2010年1月)。
同样的事情'
edit
'在交互式重新绑定期间执行,除之外,它只允许您编辑提交消息而不将控制权返回给shell 。这是非常有用的。
当前如果你想清理你的提交消息,你必须:
<$ p $
$ b
$ git rebase -i next
然后将所有提交设置为编辑。然后在每一个上:
#在编辑器中更改消息。
$ git commit --amend
$ git rebase --continue
使用'
reword
'而不是'编辑
'可以让您跳过git-commit
和git-rebase
调用。
I was trying to edit an old commit message as explained here.
The thing is that now, when I try to run rebase -i HEAD~5
it says interactive rebase already started
.
So then I try: 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?
It says:
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
It does not mean:
type again
git rebase -i HEAD~3
Try to not typing git rebase -i HEAD~3
when exiting the editor, and it should work fine.
(otherwise, in your particular situation, a git rebase -i --abort
might be needed to reset everything and allow you to try again)
As Dave Vogt mentions in the comments, git rebase --continue
is for going to the next task in the rebasing process, after you've amended the first commit.
Also, Gregg Lind mentions in his answer the reword
command of git rebase
:
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上更改旧的提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!