如何使用atom文本编辑器修复git commit

问题描述 投票:0回答:4

我在使用 Atom 文本编辑器提交文件时遇到问题

我在 Git Bash

中使用过

git config --global core.editor "atom --wait"

但是当提交这样的文件时:

git commit

出现此错误:

hint: Waiting for your editor to close the file... 'C:\Users\SALAH' is not recognized as an internal or external command,
operable program or batch file.

Aborting commit due to empty commit message.


但是当使用 Sublime Text 作为我的文本编辑器时,如下所示:

git config --global core.editor "'C:\Program Files\Sublime Text 3\sublime_text.exe' -n -w"

承诺完美发挥作用

这是 atom 的问题或有关 PATH 的问题...


任何建议我都会感激

git terminal sublimetext3 atom-editor
4个回答
1
投票

我也遇到了类似的问题,然后我发现我的用户名中的两个单词之间有一个空格。

Git 定向到路径,但在用户名 ('C:\Users\SALAH') 中的空格之前停止并抛出以下错误 -

hint: Waiting for your editor to close the file... 'C:\Users\SALAH' is not 
recognized as an internal or external command,
operable program or batch file.

Aborting commit due to empty commit message.

解决方案 = 将您的用户名更改为一个单词或不带空格。您可以按照此特定视频更改您的用户名,而无需重新安装 Windows。

https://www.youtube.com/watch?v=J_rTOA4gXJI


1
投票

在队列中;

git config --global core.editor "atom --wait"

将“atom”替换为atom应用程序的直接路径。用单引号将路径引起来。

例如;

git config --global core.editor "'C:\Users\name\AppData\Local\atom\app-1.53.0\atom.exe' --wait"

0
投票

需要使用atom.exe的真实路径

我的命令如下所示:

$ git config --global core.editor "C:/Users/name/AppData/Local/atom/atom.exe"

这对我有用。你也可以尝试一下。

祝你好运!


0
投票

解决方案:

  1. 找到您的
    .gitconfig
    文件。可能在
    C:\Users\Username\.gitconfig
    下。
  2. 编辑参数
    core.editor
    。在 editor= 后面的两边添加
    单引号
    ,这是文本编辑器的路径。

就我而言,原始文件就像

[core]
    editor = C:\\Program Files\\Sublime Text\\sublime_text.exe

你应该将其更改为

[core]
    editor = 'C:\\Program Files\\Sublime Text\\sublime_text.exe'

该问题可能是由编辑器路径中的空格引起的。我遇到了类似的问题如下:

hint: Waiting for your editor to close the file... C:\Program Files\Sublime Text\sublime_text.exe: line 1: C:Program: command not found
error: There was a problem with the editor 'C:\Program Files\Sublime Text\sublime_text.exe'.
Please supply the message using either -m or -F option.

使用

git commit
而不使用
-m
-F
参数将使 git 调用文本编辑器来编辑提交消息。调用过程是使用 cmd 进行的,但如果没有引号,它无法计算文件路径中的空间。因此问题就这样解决了。

© www.soinside.com 2019 - 2024. All rights reserved.