Git rebase --continue 不打开编辑器

标签 git

在正常的 rebase 冲突后调用 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.
Git rebase documentation 中有以下段落

Commit Rewording When a conflict occurs while rebasing, rebase stops and asks the user to resolve. Since the user may need to make notable changes while resolving conflicts, after conflicts are resolved and the user has run git rebase --continue, the rebase should open an editor and ask the user to update the commit message. The merge backend does this, while the apply backend blindly applies the original commit message.


所以我尝试切换到应用后端,但它仍然失败:
$ 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.
如何强制 Git 盲目应用提交消息?

最佳答案

我发现的一种解决方法是指定从 core.commentChar 检测到的 .git/rebase-merge/message (此处为 @ ):

git -c core.commentChar=@ rebase --continue

关于Git rebase --continue 不打开编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64276769/

相关文章:

git - 为什么我应该将我的 Wiki 存储在单独的存储库中?

git - 为什么不应该从服务器中删除标签?

git - 忘记创建新分支。如何将更改转移到新分支

git - 备份 git 服务器以进行灾难管理阶段

git - 使用 git filter-branch 删除除一个子目录之外的所有内容

git - 组合 git `continue` 命令

git - .gitignore 不忽略 node_modules

Git 预提交 Hook 在 GitHub for mac 中失败(在命令行上工作)

git - 在 cvsimport 之后告诉 git 两个用户是等价的

git - 防止人们使用不同的作者姓名推送 git commit?