VSCode 作为适用于 Linux 的 Windows 子系统 (WSL) 上的 Git 编辑器

Obe*_*yda 6 git commit-message visual-studio-code windows-subsystem-for-linux

语境

系统信息(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
Run Code Online (Sandbox Code Playgroud)

系统信息 (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
Run Code Online (Sandbox Code Playgroud)

git

我的~/.gitconfig

[core]
    editor = code --wait
Run Code Online (Sandbox Code Playgroud)

问题:

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

当我编写提交消息、保存并退出时,我会在终端中看到以下内容:

Aborting commit due to empty commit message.
Run Code Online (Sandbox Code Playgroud)

笔记

当我这样做时:

  1. 跑步git commit;

  2. 在 vscode 中写入提交消息(例如:初始化 repo),保存并关闭;

  3. 之后Aborting commit due to empty commit message.,我git commit再次跑步;

VSCode 将打开并显示我在步骤 2 中编写的相同提交消息(即:Initialize repo

noo*_*riq 3

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

本质上,您只需要安装远程开发扩展包