سؤال

I get following error message, when I try to run git rebase -i for squashing my commit:

/usr/libexec/git-core/git-sh-setup: line 112: mate: command not found

How does git look for the editor? From the git-sh-setup file, I can only see this method:

git_editor() {                                                                       
    if test -z "${GIT_EDITOR:+set}" 
    then                                                                             
        GIT_EDITOR="$(git var GIT_EDITOR)" || return $?                              
    fi                                                                               
    eval "$GIT_EDITOR" '"$@"'                                                                                                                                                    
} 
هل كانت مفيدة؟

المحلول

There is a setting in ~/.gitconfig like this:

[core]
    editor = mate

If you have textmate added to you PATH then you can just changed it to: editor = mate. Just make sure that it is added there.

echo $PATH to check if textmate is there.


You can also change the configuration option through git config. The option to chage is core.editor. For example:

$ git config core.editor        # the current set editor
mate
$ git config core.editor vim    # change editor to vim
$ git config core.editor
vim

to make the setting available in all your repositories add --global flag to git config

$ git config --global core.editor <editor-of-choice>

From git help config manpage:

core.editor
Commands such as commit and tag that lets you edit messages by launching an editor uses the value of this variable when it is set, and the environment variable GIT_EDITOR is not set. See git-var(1).

نصائح أخرى

As you can see in that script, it uses git var, which according to git help var does:

GIT_EDITOR

Text editor for use by git commands. The value is meant to be interpreted by the shell when it is used. Examples: ~/bin/vi, $SOME_ENVIRONMENT_VARIABLE, "C:\Program Files\Vim\gvim.exe" --nofork.

The order of preference is the $GIT_EDITOR environment variable, then core.editor configuration, then $VISUAL, then $EDITOR, and then finally vi.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top