【问题标题】:Git-commit unable to open vimGit-commit 无法打开 vim
【发布时间】:2015-01-11 21:35:20
【问题描述】:

最近我在终端中安装了bash-it。现在,当我尝试执行 git commit 时,终端会显示此错误:

/usr/bin/mate -w: /usr/bin/mate: No such file or directory error: cannot run /usr/bin/mate -w: No such file or directory error: There was a problem with the editor '/usr/bin/mate -w'. Please supply the message using either -m or -F option.

bash-it之前,commit命令正确打开vim。 当然,我尝试将 git 中的 core.editor 更改为“vim”,但它无论如何都不起作用。

你能帮我解决这个问题吗?我真的很喜欢 vim,它超级简单快捷……我不想使用 TextMate 来编辑提交消息。

PS:我使用的是 Mac OSX

【问题讨论】:

  • 检查您的 EDITORVISUAL 环境变量。其中一个可能指向/usr/bin/mate
  • 谢谢保罗,你是对的,我必须环境变量指向:# Set my editor and git editor export EDITOR="/usr/bin/mate" export GIT_EDITOR='/usr/bin/mate -v' 我编辑了我的 .bash_profile 并将其删除,设置 vim:# Set my editor and git editor export EDITOR="/usr/bin/vim" export GIT_EDITOR='/usr/bin/vim'

标签: git bash vim commit git-commit


【解决方案1】:

正如“abalos”的回答,

git config --global core.editor vim

如果您不想使用 vim 或在某些情况下没有安装 vim, 您也可以使用nano编辑器

git config --global core.editor nano

【讨论】:

  • 我设置了git config --global core.editor subl,但仍然出现错误。 ``` git commit 致命:无法运行 subl:没有这样的文件或目录错误:无法启动编辑器 'subl' 请使用 -m 或 -F 选项提供消息。 ```
【解决方案2】:

如果其他答案不起作用,请尝试export GIT_EDITOR=vim

【讨论】:

    【解决方案3】:

    问题是我的.bash_profile 中有两个指向/usr/bin/mate 的环境变量 所以我编辑它们指向vim

    【讨论】:

      【解决方案4】:

      尝试使用以下命令。应该能够将您的编辑器设置回 vi 或 vim。但是,您可能必须提供 vim 的绝对路径。

      git config --global core.editor vim
      

      【讨论】:

      • 正如我所说,我的 core.editor 已经设置为 vim,问题是我必须在我的 .bash_profile 中设置指向 /usr/bin/mate 的环境变量
      • 对我来说,这解决了当我尝试重新设置文本文件时会在我的编辑器中打开的问题,我需要使用 vim 重命名提交消息并遍历最近的几次提交
      猜你喜欢
      • 1970-01-01
      • 2020-04-29
      • 2011-08-31
      • 2023-04-10
      • 2015-05-18
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 2019-01-12
      相关资源
      最近更新 更多