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

GitVimEditorGit Rebase

Git Problem Overview


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).

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

I know in vim I can do:

:%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)

Git Solutions


Solution 1 - Git

Try adding the GIT_EDITOR environment variable before your command, like so:

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

For example, to use nano I would type:

GIT_EDITOR=nano git rebase -i abcdef1234

Solution 2 - Git

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

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

It is a custom CLI app written in node specifically for interactive 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 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSridhar SarnobatView Question on Stackoverflow
Solution 1 - GitRob BajorekView Answer on Stackoverflow
Solution 2 - GitbarsjuView Answer on Stackoverflow