最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】cygwin中用git去config配置用户名和邮箱出错:error: cannot run vi: No such file or directory

Git crifan 6632浏览 0评论

折腾:

【记录】将googlecode上面的crifanLib迁移到Github上

期间,出错:

cygwin git config error cannot run vi

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config --global user.name "Crifan Li"

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config --global user.email [email protected]

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git commit --amend --reset-author
error: cannot run vi: No such file or directory
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

【折腾过程】

1.搜:

cygwin git config error cannot run vi No such file or directory

参考:

How can I set up an editor to work with Git on Windows? – Stack Overflow

去试试:

创建了个文件:

git_config_npp.sh

内容是:

#!/bin/sh
"D:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"

放在了cygwin根目录:

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ ls /
bin  cygdrive  Cygwin.bat  Cygwin.ico  Cygwin-Terminal.ico  dev  etc  git_config_npp.sh  home  lib  opt  proc  sbin  srv  tmp  usr  var

然后再去试试:

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config core.editor /git_config_npp.sh

然后再去试试之前的命令,结果第三个reset-author后就打开了npp,然后npp就停在那了:

cygwin git commit show npp edit

好像需要手动去关闭npp?

不过手动去改了下名字的注释:

change note text before commit using npp

然后关闭npp。

然后窗口就恢复到cygwin了:

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config core.editor /git_config_npp.sh

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config --global user.name "Crifan Li"

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git config --global user.email [email protected]

Administrator@PC-20131018OHXV /cygdrive/e/dev_root/git/crifanLib
$ git commit --amend --reset-author
[master 1ae903a] change local name to crifan
 10 files changed, 12600 insertions(+), 0 deletions(-)
 create mode 100755 c/crifanLib.c
 create mode 100755 csharp/crifanLib.cs
 create mode 100755 csharp/crifanLibAmazon.cs
 create mode 100755 csharp/crifanLibAws.cs
 create mode 100755 csharp/crifanLibGoogle.cs
 create mode 100755 go/crifanLib.go
 create mode 100755 java/crifanLib.java
 create mode 100755 java/crifanLibSongtaste.java
 create mode 100755 php/crifanLib.php
 create mode 100755 python/crifanLib.py

git config then commit successfully

如此,即可正常的用git的config了。

【总结】

cygwin中用git去config时,出现:

error: cannot run vi: No such file or directory

是因为没有默认的编辑器。

在windows中,此处已经安装了Notepad++的情况下,就可以去设置npp作为git的编辑器了。

然后通过:

1.创建了个文件:

git_config_npp.sh

内容是:

#!/bin/sh
"D:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"

放在了cygwin根目录

2.再去:

git config core.editor /git_config_npp.sh

3.随后即可正常的:

git config --global user.name "Crifan Li"

git config --global user.email [email protected]

了。

3.以及:

git commit --amend --reset-author

此时会调用npp去让你输入修改名字后,需要添加的注释。

用npp加上你所需要写的注释内容,保存后,关闭npp即可。

然后git即可正常的执行commit操作了。

转载请注明:在路上 » 【已解决】cygwin中用git去config配置用户名和邮箱出错:error: cannot run vi: No such file or directory

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 1.571 seconds, using 22.10MB memory