使用 Vim 进行提交时出错
Errors using Vim for commit
Windows 7 x64
无法理解我的错误。
$ git config --global core.editor vim
$ git commit
.gitconfig
路径:editor = vim
E325: ATTENTION
Error: There was a problem with the editor 'vim'. Please supply the message using either -m or -F option.
$ git config --global core.editor "'vim' -w"
$ git commit
.gitconfig
路径:editor = 'vim' -w
当 Vim 打开时,它是空的,但应该包含类似 $ git diff
的内容
$ git config --global --unset core.editor
$ git commit
E325 ATTENTION
Aborting commit due to empty commit message.
我以为Vim默认使用。
$ EDITOR=vim
$ git commit
E325 ATTENTION
Aborting commit due to empty commit message.
$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 1 2017 21:25:47)
Заплатки: 1-606
Скомпилирован <alexpux@gmail.com>
Огромная версия без графического интерфейса.
Включённые (+) и отключённые (-) особенности:
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
-balloon_eval +folding +mouse_xterm +termguicolors
-browse -footer +multi_byte +terminfo
++builtin_terms +fork() +multi_lang +termresponse
+byte_offset +gettext -mzscheme +textobjects
+channel -hangul_input +netbeans_intg +timers
+cindent +iconv +num64 +title
-clientserver +insert_expand +packages -toolbar
+clipboard +job +path_extra +user_commands
+cmdline_compl +jumplist +perl/dyn +vertsplit
+cmdline_hist +keymap +persistent_undo +virtualedit
+cmdline_info +lambda +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak +python/dyn +vreplace
+cscope +lispindent +python3/dyn +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con -lua +rightleft +writebackup
+diff +menu +ruby/dyn -X11
+digraphs +mksession +scrollbind -xfontset
-dnd +modify_fname +signs -xim
-ebcdic +mouse +smartindent -xpm
+emacs_tags -mouseshape +startuptime -xsmp
+eval +mouse_dec +statusline -xterm_clipboard
+ex_extra -mouse_gpm -sun_workshop -xterm_save
+extra_search -mouse_jsbterm +syntax
+farsi +mouse_netterm +tag_binary
общесистемный файл vimrc: "/etc/vimrc"
пользовательский файл vimrc: "$HOME/.vimrc"
второй пользовательский файл vimrc: "~/.vim/vimrc"
пользовательский файл exrc: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
значение $VIM по умолчанию: "/etc"
значение $VIMRUNTIME по умолчанию: "/usr/share/vim/vim80
"
Параметры компиляции: gcc -c -I. -Iproto -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2
-I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Сборка: gcc -L. -pipe -fstack-protector -pipe -Wl,
--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lintl -Wl,
--enable-auto-import -Wl,--export-all-symbols -Wl,
--enable-auto-image-base -fstack-protector-strong
-L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt
我不知道那是什么,但我重新加载了存储库并且错误消失了,谢谢大家的建议。
我今天遇到了这个错误。如果它可以帮助其他人,我会在这里发布我的解决方案。首先,介绍一下我是如何陷入出现此错误的困境的(TL;DR?跳转到“解决方案”部分)。
我已经 VIM 设置为我的默认编辑器并正在编写我的提交消息。像往常一样,我忘记使用 Shift+Insert 来粘贴一行文本,而是使用 Ctrl+V。我的脑袋仍然处于 Windows 模式,我试图通过按 Ctrl+Z 来“撤销”我的错误(这太自然了)。一连串的 ESC 按下并尝试 :q!
之后,我出局了。 VIM 不会回应任何事情。我不得不使用 Windows 任务管理器终止进程。从那时起,每次 Git 启动 VIM(对于 commit
消息,对于 rebase -i
等),我都会收到 OP 的错误。
然而,我注意到问题只发生在我搞砸时所在的存储库中 VIM。 Git 的 VIM 启动在其他回购协议中运行良好。谷歌搜索,我想起了 VIM 的交换文件。
解决方案
果然,我在受影响的存储库的 .git 目录中发现了一个流氓交换文件,而且,这是针对 COMMIT_EDITMSG 文件的。删除这个交换文件 (*.swp) 解决了这个问题。
Windows 7 x64
无法理解我的错误。
$ git config --global core.editor vim
$ git commit
.gitconfig
路径:editor = vim
E325: ATTENTION
Error: There was a problem with the editor 'vim'. Please supply the message using either -m or -F option.
$ git config --global core.editor "'vim' -w"
$ git commit
.gitconfig
路径:editor = 'vim' -w
当 Vim 打开时,它是空的,但应该包含类似 $ git diff
$ git config --global --unset core.editor
$ git commit
E325 ATTENTION
Aborting commit due to empty commit message.
我以为Vim默认使用。
$ EDITOR=vim
$ git commit
E325 ATTENTION
Aborting commit due to empty commit message.
$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 1 2017 21:25:47)
Заплатки: 1-606
Скомпилирован <alexpux@gmail.com>
Огромная версия без графического интерфейса.
Включённые (+) и отключённые (-) особенности:
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
-balloon_eval +folding +mouse_xterm +termguicolors
-browse -footer +multi_byte +terminfo
++builtin_terms +fork() +multi_lang +termresponse
+byte_offset +gettext -mzscheme +textobjects
+channel -hangul_input +netbeans_intg +timers
+cindent +iconv +num64 +title
-clientserver +insert_expand +packages -toolbar
+clipboard +job +path_extra +user_commands
+cmdline_compl +jumplist +perl/dyn +vertsplit
+cmdline_hist +keymap +persistent_undo +virtualedit
+cmdline_info +lambda +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak +python/dyn +vreplace
+cscope +lispindent +python3/dyn +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con -lua +rightleft +writebackup
+diff +menu +ruby/dyn -X11
+digraphs +mksession +scrollbind -xfontset
-dnd +modify_fname +signs -xim
-ebcdic +mouse +smartindent -xpm
+emacs_tags -mouseshape +startuptime -xsmp
+eval +mouse_dec +statusline -xterm_clipboard
+ex_extra -mouse_gpm -sun_workshop -xterm_save
+extra_search -mouse_jsbterm +syntax
+farsi +mouse_netterm +tag_binary
общесистемный файл vimrc: "/etc/vimrc"
пользовательский файл vimrc: "$HOME/.vimrc"
второй пользовательский файл vimrc: "~/.vim/vimrc"
пользовательский файл exrc: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
значение $VIM по умолчанию: "/etc"
значение $VIMRUNTIME по умолчанию: "/usr/share/vim/vim80
"
Параметры компиляции: gcc -c -I. -Iproto -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2
-I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Сборка: gcc -L. -pipe -fstack-protector -pipe -Wl,
--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lintl -Wl,
--enable-auto-import -Wl,--export-all-symbols -Wl,
--enable-auto-image-base -fstack-protector-strong
-L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt
我不知道那是什么,但我重新加载了存储库并且错误消失了,谢谢大家的建议。
我今天遇到了这个错误。如果它可以帮助其他人,我会在这里发布我的解决方案。首先,介绍一下我是如何陷入出现此错误的困境的(TL;DR?跳转到“解决方案”部分)。
我已经 VIM 设置为我的默认编辑器并正在编写我的提交消息。像往常一样,我忘记使用 Shift+Insert 来粘贴一行文本,而是使用 Ctrl+V。我的脑袋仍然处于 Windows 模式,我试图通过按 Ctrl+Z 来“撤销”我的错误(这太自然了)。一连串的 ESC 按下并尝试 :q!
之后,我出局了。 VIM 不会回应任何事情。我不得不使用 Windows 任务管理器终止进程。从那时起,每次 Git 启动 VIM(对于 commit
消息,对于 rebase -i
等),我都会收到 OP 的错误。
然而,我注意到问题只发生在我搞砸时所在的存储库中 VIM。 Git 的 VIM 启动在其他回购协议中运行良好。谷歌搜索,我想起了 VIM 的交换文件。
解决方案
果然,我在受影响的存储库的 .git 目录中发现了一个流氓交换文件,而且,这是针对 COMMIT_EDITMSG 文件的。删除这个交换文件 (*.swp) 解决了这个问题。