git rebase --editor=/something/other/than/vim? (为了更容易压扁)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19713861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:17:44  来源:igfitidea点击:

git rebase --editor=/something/other/than/vim? (for easier squashing)

gitvimeditorgit-rebase

提问by Sridhar Sarnobat

I happily use vim as my default editor for commits, and do not wish to change it. However, when it comes to rebasing, I find myself squashing dozens and dozens of commits which I find much easier with an interactive editor like Textwrangler (substituting "pick" with "squash" in all but the top commit).

我很高兴使用 vim 作为我的默认提交编辑器,并且不想更改它。然而,当谈到变基时,我发现自己压缩了几十个提交,我发现使用 Textwrangler 这样的交互式编辑器要容易得多(除了顶部提交之外,所有内容都用“squash”代替“pick”)。

Is there any way to specify an alternate editor for a one-off rebase command?

有没有办法为一次性 rebase 命令指定备用编辑器?

I know in vim I can do:

我知道在 vim 中我可以做到:

:%s/pick/squash/

but that has its own minor annoyances.

但这有其自身的小烦恼。

EDIT- as stated in the comments, you can squash all but the top commit very efficiently by going to the 2nd line and executing

编辑- 如评论中所述,您可以通过转到第二行并执行来非常有效地压缩除最高提交之外的所有提交

:,$s/pick/squash/

(note the comma and dollar are different to the original)

(注意逗号和美元与原文不同)

回答by Rob Bajorek

Try adding the GIT_EDITORenvironment variable before your command, like so:

尝试GIT_EDITOR在您的命令之前添加环境变量,如下所示:

GIT_EDITOR=<editor of choice> git rebase <...>

For example, to use nanoI would type:

例如,要使用nano我会输入:

GIT_EDITOR=nano git rebase -i abcdef1234

回答by barsju

There is an even better option for all your interactive rebase.

对于所有交互式变基,还有一个更好的选择。

https://github.com/sjurba/rebase-editor

https://github.com/sjurba/rebase-editor

It is a custom CLI app written in node specifically for interactive rebase.

它是一个用 node 编写的自定义 CLI 应用程序,专门用于交互式 rebase。

To install:

安装:

npm install -g rebase-editor
git config --global sequence.editor rebase-editor 

Or with yarn:

或者用纱线:

yarn global add rebase-editor
git config --global sequence.editor rebase-editor