Git commit messages lost by vi

前端 未结 2 1818
旧时难觅i
旧时难觅i 2021-02-02 10:03

I\'m a clumsy typist, and I don\'t use vi/vim very often, but I do use it for commit messages. However, if you type a wrong command while editing a commit message (:Wq

相关标签:
2条回答
  • 2021-02-02 10:52

    You should set vim to not detach from the shell and be in the foreground. You can do this with the following command:

    git config --global core.editor vim -f
    

    From the man:

       -f          Foreground.  For the GUI version, Vim will not fork and detach from the shell it
                   was  started in.  On the Amiga, Vim is not restarted to open a new window.  This
                   option should be used when Vim is executed by a program that will wait  for  the
                   edit  session  to  finish (e.g. mail).  On the Amiga the ":sh" and ":!" commands
                   will not work.
    
    0 讨论(0)
  • 2021-02-02 10:52

    As mentioned in several posts vim is exiting with a exit code other than zero. You can fix it by explicitely setting the git editor to the full vim path:

    git config --global core.editor /usr/bin/vim
    

    If I remember correctly I fixed the issue by installing a homebrewed vim. Make sure your path is set correctly then.

    0 讨论(0)
提交回复
热议问题