第一种方法,通过Git配置:
git -c core.editor=true rebase --continue
或者,使用环境变量:
GIT_EDITOR=true git rebase --continue
这将覆盖编辑器git
用于消息确认。true
命令只是以零退出代码结束。它使git
继续rebase
就像用户关闭交互式编辑器一样。
在 Windows 上,您需要use CMD /V /C https://stackoverflow.com/a/31824572/6309
cmd /V /C "set "GIT_EDITOR=true" && git rebase --continue
在这两个操作系统中,您都可以使用别名
# Linux
alias grc='GIT_EDITOR=true git rebase --continue'
# Windows
doskey grc=cmd /V /C "set "GIT_EDITOR=true" && git rebase --continue"
然后一个简单的grc
将足以继续变基without编辑器弹出。
大卫·加德纳 https://stackoverflow.com/users/25702/david-gardiner添加评论 https://stackoverflow.com/questions/43489971/how-to-suppress-the-editor-for-git-rebase-continue/45783848#comment130045522_45783848:
在 PowerShell 中,使用:
$env:GIT_EDITOR = "true -and git rebase --continue"
然后整理
$env:GIT_EDITOR = ""
要全局设置(没有别名),也许可以考虑这种方法 https://stackoverflow.com/a/64350016/6309:
指定从 .git/rebase-merge/message 检测到的 core.commentChar(此处为 @):
git --global core.commentChar @
还有GIT_SEQUENCE_EDITOR=: https://stackoverflow.com/a/54970726/6309,但你不能总是将其保留为该值,因为这会破坏你所在的所有变基操作want一位编辑。
这就是为什么使用别名仍然是最灵活和准确的方法,而不是依赖可能会破坏其他变基编辑器用例的全局设置。