【问题标题】:VSCode as Git editor on Windows Subsystem for linux (WSL)VSCode 作为 Windows Subsystem for linux (WSL) 上的 Git 编辑器
【发布时间】:2019-02-11 14:56:19
【问题描述】:

上下文

系统信息(Windows)

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.17134 N/A Build 17134
...
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~3696 Mhz
BIOS Version:              American Megatrends Inc. 2.20, 10/27/2017

系统信息 (WSL)

OS: Debian
Kernel: x86_64 Linux 4.4.0-17134-Microsoft
Shell: zsh 5.3.1
CPU: Intel Core i7-8700K CPU @ 3.696GHz
RAM: 8041MiB / 16344MiB

Git

我的~/.gitconfig 中有这个:

[core]
    editor = code --wait

问题:

当我运行git commit 时,vscode 以C:\mnt\$PathToRepo$\.git\COMMIT_EDITMSG 开头,但是这个文件是空的(它应该有要提交的更改+一个差异)。

当我编写提交消息,保存并退出时,我在终端中得到了这个:

Aborting commit due to empty commit message.

注意

当我这样做时:

  1. 运行git commit

  2. 在 vscode 中写入提交信息(例如:Initialize repo),保存并关闭;

  3. Aborting commit due to empty commit message.之后,我再次运行git commit

VSCode 将使用我在第 2 步中编写的相同提交消息打开(即:Initialize repo

【问题讨论】:

标签: git visual-studio-code windows-subsystem-for-linux commit-message


【解决方案1】:

如果重点是在 vscode 上使用 WSL git,这里是官方解决方案:https://code.visualstudio.com/docs/remote/wsl

基本上,您只需要安装Remote Development Extension Pack

【讨论】:

    【解决方案2】:

    在尝试更多方法时,此解决方案有效:https://github.com/Microsoft/vscode/issues/27101#issuecomment-306994732

    整个问题是为 Windows 转换文件的位置。使用诸如链接到那里的脚本 (https://github.com/Milly/wslpath) 和包装脚本将允许消息在 vscode 中正确打开。我个人删除了包装脚本中的 -n 选项,因为我更喜欢选项卡。

    【讨论】:

      猜你喜欢
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 2016-12-13
      • 2021-02-23
      • 2018-10-16
      • 2017-11-10
      • 1970-01-01
      相关资源
      最近更新 更多