git rebase --continue当在正常的变基冲突后调用时,编辑器 ( GIT_EDITOR) 打开并要求修改提交消息。因为提交消息可能包含前导 #,所以这可能会失败。
$ export GIT_EDITOR=true
$ git rebase --continue
Aborting commit due to empty commit message.
error: could not commit staged changes.
Run Code Online (Sandbox Code Playgroud)
在Git rebase 文档中有以下段落
提交改写 当变基时发生冲突时,变基会停止并要求用户解决。由于用户在解决冲突时可能需要进行显着更改,因此在解决冲突并且用户运行 git rebase --continue 后,rebase 应打开一个编辑器并要求用户更新提交消息。合并后端执行此操作,而应用后端则盲目应用原始提交消息。
所以我尝试切换到apply后端,但仍然失败:
$ export GIT_EDITOR=true
$ git config rebase.backend apply
$ $ git config --list | grep backend
rebase.backend=apply
$ git rebase --continue
Aborting commit due to empty commit message.
error: could not commit staged changes.
Run Code Online (Sandbox Code Playgroud)
如何强制Git盲目应用提交消息?
我发现的解决方法是指定core.commentChar从.git/rebase-merge/message(此处@)检测到的:
git -c core.commentChar=@ rebase --continue
Run Code Online (Sandbox Code Playgroud)